Comment écrire régulièrement une URL de balise (python ou js)
怪我咯
怪我咯 2017-05-18 10:51:20
0
2
631
<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>

Je veux obtenir le lien en href

Les trois premiers des 6 liens remplissent les conditions. Comment écrire l'expression régulière (c'est-à-dire que le lien doit avoir le paramètre viewkey page viewtypecategory)

Les deuxième et troisième liens sont les mêmes. Comment les dupliquer (sous python)

怪我咯
怪我咯

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

répondre à tous(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))
伊谢尔伦

Extraire les trois premiers liens :

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

Déduplication :

new_links=set(links)

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!