【发布时间】:2019-01-07 12:11:43
【问题描述】:
我想从下面的 Div 中抓取产品信息,但是当我美化 HTML 时,我无法在 HTML 中找到主要的 DIV。
<div class="c2p6A5" data-qa-locator="product-item" data-tracking="product-card"
我试图获取的元素在以下脚本中。我需要知道如何从下面的脚本中提取数据:
<script type="application/ld+json"></script>
我的代码如下:
import requests
from bs4 import BeautifulSoup
url = "https://www.daraz.pk/catalog/?q=dell&_keyori=ss&from=input&spm=a2a0e.searchlist.search.go.57446b5079XMO8"
page = requests.get(url)
print(page.status_code)
print(page.text)
soup = BeautifulSoup(page.text, 'lxml')
print(soup.prettify())
【问题讨论】:
标签: python-3.x web-scraping beautifulsoup jupyter-notebook scrape