2024-04-29 14:25:51 发布
网友
我尝试使用Scrapy抓取以下网址: http://www.walgreens.com/search/results.jsp?Ntt=bounty+paper+towel
但是返回的URL不完整。因为当我这么做的时候
scrapy shell the_url_above
那么
这个网页没有完全加载。所以我的问题是:
该页面的数据似乎是用javascript加载的。如果您检查页面(例如firebug network选项卡),您会看到一旦加载了基本页面,javascript就会加载产品,javascript会向http://www.walgreens.com/svc/products/search发送一个POST请求,其中包含以下内容:
http://www.walgreens.com/svc/products/search
{"p":"1", # seems to be page number "s":"15", # page size "sort":"relevance", "view":"allView", "geoTargetEnabled":false, "q":"bounty paper towel", # search query "requestType":"search", "deviceType":"desktop"}
您可以使用scrapy发送此请求:
您应该会收到一个json对象,其中充满了产品数据。在
您甚至可以通过以下链接在浏览器中查看响应: http://www.walgreens.com/svc/products/search?p=1&s=15&sort=relevance&view=allView&geoTargetEnabled=false&q=bounty%20paper%20towel&requestType=search&deviceType=desktop
该页面的数据似乎是用javascript加载的。如果您检查页面(例如firebug network选项卡),您会看到一旦加载了基本页面,javascript就会加载产品,javascript会向
http://www.walgreens.com/svc/products/search
发送一个POST请求,其中包含以下内容:您可以使用scrapy发送此请求:
^{pr2}$您应该会收到一个json对象,其中充满了产品数据。在
您甚至可以通过以下链接在浏览器中查看响应: http://www.walgreens.com/svc/products/search?p=1&s=15&sort=relevance&view=allView&geoTargetEnabled=false&q=bounty%20paper%20towel&requestType=search&deviceType=desktop
相关问题 更多 >
编程相关推荐