【发布时间】:2019-07-14 23:28:39
【问题描述】:
我过去曾搜索过几个网站,但 newegg.ca 的结构与其他网站不同。我使用 BeautifulSoup 仅提取产品的名称和价格。 我要抓取的网站是https://www.newegg.ca/p/N82E16875606157
到目前为止,我已经使用以下方法刮掉了标题:
page = requests.get(URL, headers=headers)
page_soup = BeautifulSoup(page.content, "html.parser")
global ng_title
ng_title = page_soup.find(id="grpDescrip_h").get_text().strip()
print(ng_title)
输出:
Huawei P30 4G LTE Cell Phone 6.1" Breathing Crystal 128GB 6GB RAM
但我在提取价格时遇到了困难。也许我需要实现一个 for 循环?或者还有其他方法。
感谢您的帮助,谢谢!
【问题讨论】:
标签: python html web-scraping beautifulsoup