How to write regular a tag url (python or js)
怪我咯
怪我咯 2017-05-18 10:51:20
0
2
679
<a target="blank"href="http://a.b.c.d/abc.php?viewkey=11111111111d5c2a51d1e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>
<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>

<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>


<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp"></a>

<a target="blank"href="http://a.b.c.d/abc"></a>


<a target="blank"href="http://a.b.c.d/123"></a>

I want to get the link in href

The first three of the 6 links meet the conditions. How to write the regular form (that is, the link must have the parameter viewkey page viewtype category)

The second and third links are the same. How to repeat them (under python)

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
黄舟
# python 2.7

import re

a = '''<a target="blank"href="http://a.b.c.d/abc.php?viewkey=11111111111d5c2a51d1e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>
<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>

<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp;page=1&amp;viewtype=basic&amp;category=rf"></a>


<a target="blank"href="http://a.b.c.d/abc.php?viewkey=6d7a7f6a6e9c2a5191e2&amp"></a>

<a target="blank"href="http://a.b.c.d/abc"></a>


<a target="blank"href="http://a.b.c.d/123"></a>'''

print set(re.findall('''(?=.*(?:viewkey))(?=.*(?:page))(?=.*(?:viewtype))(?=.*(?:category))href=["']([^'"]+)''', a))
伊谢尔伦

Extract the first three links:

links= re.findall(r'href=\"(.*?=rf)\"',l_string,re.S)

Remove duplicates:

new_links=set(links)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template