简体   繁体   中英

How do I use findall in html string?

My code:

mug_cup_link = '.....'
mc_source = urlopen(mug_cup_link).read()
name=findall('<a href="" >".*"</a>',mc_source)

I am searching for multiple names, not just a single one.

If you want to use regular expressions you to change you re this way

import re
s = """<a href="https://zombieunlimited.com/rancid-santa-mug/" >Rancid Santa Mug</a> """
print(re.search('<a.*>(.*)<\/a>', s).start(1))

Hope it works for you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM