【发布时间】:2020-12-31 19:48:51
【问题描述】:
我只想抓取一个网站并提取图像中突出显示的标签内的“作者姓名”。如何使用python3做到这一点?我遇到了困难,因为作者的名字在多个标签中。 (image with the highlighted part)
这是我为提取“标题”和“日期”而编写的代码。现在,我要提取作者姓名。
from urllib.request import urlopen
from htmldate import find_date
url = "https://indianexpress.com/article/business/companies/market-surges-
after-report-says-amazon-looking-at-40-in-reliance-retail-6591325/"
page = urlopen(url)
#print(page)
html_bytes = page.read()
html = html_bytes.decode("utf-8")
#print(html)
title_index = html.find("<title>")
start_index = title_index + len("<title>")
end_index = html.find("</title>")
title = html[start_index:end_index]
print(title)
date = find_date(url)
print(date)
【问题讨论】:
-
你尝试了什么?你能分享你的代码和网址吗?
-
我已经更新了我帖子中的代码!
标签: python python-3.x web-scraping beautifulsoup web-crawler