我正试图从一个网站上抓取电子邮件地址,在这个网站上,电子邮件嵌套在一个脚本中,而一个简单的“find/findAll+.text”并不能奏效。你知道吗
源html:
<script>EMLink('com','aol','mikemhnam','<div class="emailgraphic"><img style="position: relative; top: 3px;" src="https://www.naylornetwork.com/EMailProtector/text-gif.aspx?sx=com&nx=mikemhnam&dx=aol&size=9&color=034af3&underline=yes" border=0></div>','pcoc.officialbuyersguide.net Inquiry','onClick=\'$.get("TrackLinkClick", { LinkType: "Email", LinkValue: "mikemhnam@aol.com", MDSID: "CPC-1210", AdListingID: "" });\'')</script>
<br/>
我目前的方法是尝试“findAll+”regex表达式,如下所示:
for email in soup.findAll(class_='ListingPageNameAddress NONE'):
print(email.findAll("([\w\._]+\@([\w_]+\\.)+[a-zA-Z]+)"))
但在jupyter中,这只是返回一个[] :/
正则表达式有问题吗?或者用一种更简单的方法来梳理邮件?你知道吗
似乎您没有使用正确的} 方法,而不是
findall
方法。您需要import re
,然后使用^{findAll()
方法(注意字母“A”的大小写差异)。函数的接口是:有关详细信息,请参见
re
文档中的this section查找所有副词。你知道吗尽管regex可能会随着时间的推移而变得更加健壮,但根据我的经验,脚本标签的这些部分保持相当稳定,所以考虑使用split的计划B
相关问题 更多 >
编程相关推荐