我想抓取电子商务网站https://www.bhinneka.com/我已经解析了html,但是为什么我的解析没有包含div类上的任何文本
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
import pandas
html = urlopen("https://www.bhinneka.com/jual?cari=iphone&catId=3457215").read()
print (type(html))
soup = BeautifulSoup(html, "html.parser")
data = soup.find("div", "col-lg-3 col-md-3 col-xs-6 bt-product-catalog-item")
print(data)
这些产品是使用json资源中的javascript加载的,这就是为什么在请求的响应中找不到任何内容
您需要发出此请求才能获得产品:
您可以调整参数以获得所有页面
您在页面上看到的数据是通过JavaScript加载的。您可以使用
requests
库来模拟此调用例如:
印刷品:
相关问题 更多 >
编程相关推荐