【发布时间】:2016-12-08 03:05:45
【问题描述】:
谁能帮我提取 From 之后的测试,我想提取发件人姓名。它位于 em 标签的外面。我正在使用 python BeautifulSoup 包。
这是网页链接:http://seclists.org/fulldisclosure/2016/Jan/0
我能够成功提取电子邮件标题,因为它位于标签中。 html 页面中没有其他 div 或类。
这是页面的html代码:
这是我尝试过的
def title_spider(max_pages):
page = 0
while page <= max_pages:
url = 'http://seclists.org/fulldisclosure/2016/Jan/' + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for email_title in soup.find('b'):
title = email_title.string
print(title)
for date_stamp in soup.em:
date = date_stamp
print(date)
page += 1
title_spider(2)
`
【问题讨论】:
标签: python beautifulsoup web-crawler