简体   繁体   English

如何在 html 字符串中使用 findall?

[英]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!希望这对你有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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