【发布时间】:2018-05-23 15:55:04
【问题描述】:
我想抓取网站中的新闻链接(在下面的屏幕截图中突出显示):
当我inspect页面时,我看到我想要的链接包含在col-sm-5标签h5下的类中。我想在那个 div 类 col-sm-5 中抓取所有 4 个链接(带有标签 li)。因此,我编写了以下代码来提取链接:
import requests
page = requests.get("http://www3.asiainsurancereview.com/News","html.parser")
soup = BeautifulSoup(page.text, "html.parser")
li_box = soup.find('h5', attrs={'class': 'col_sm_5'})
print(li_box)
但是我得到的输出是none;我想它找不到标签。那么,我的问题是,如何指定查找和提取链接所需的类、标签或其他信息?
【问题讨论】:
标签: python html web-scraping beautifulsoup