我正在尝试从下一页解析Amazon Standard Identification Number(ASIN)。
https://www.amazon.com/dp/B075GYWPCJ
但是,我无法从scrapy
响应中选择包含ASIN的表。如何选择表格,以便解析表格中的数据?
import scrapy
from scrapy.crawler import CrawlerProcess
class AmazonSpider(scrapy.Spider):
name = 'amazon.com'
def start_requests(self):
yield scrapy.Request('https://www.amazon.com/dp/B075GYWPCJ', self.parse)
def parse(self, response):
# This works.. :)
print(response.xpath('//table[@id="HLCXComparisonTable"]'))
# This doesn't work.. :(
print(response.xpath('//table[@id="productDetails_detailBullets_sections1"]'))
process = CrawlerProcess()
process.crawl(AmazonSpider)
process.start()
答案 0 :(得分:0)
在亚马逊上,很多东西都是动态加载的。打开页面时,您尝试获取的表不会加载到DOM中。您需要以某种方式触发页面以加载该内容才能获取它。