尝试 运行 scrapy shell 命令获取 .gg 网站,但 returns 一个空括号
Trying to run scrapy shell command for a .gg website, but returns an empty bracket
我在 scrapy shell 中尝试 运行 命令 response.css(".hero-name::text").extract() 但返回了一个空括号.
我已采取的步骤
scrapy shell 'https://msf.gg/characters'
>>> response.css(".hero-name::text").extract()
[] 返回空括号。
我也试过 运行 xpath 和相同的结果
>>> response.xpath("/html/body/div[1]/section/div/div/ul/li[1]/div[3]/h4/text()").extract()
[]
首先,
你应该 scrapy shell 'https://msf.gg/characters'
而不是 scrapy shell 两次。
其次,
它是一个动态呈现的页面,即 JS 呈现的页面;
因此scrapy无法定位那些元素,你可以view(response)
看看; (这基本上就是 scrapy 看到的)
一个解决方案是使用requests-html or selenium
我在 scrapy shell 中尝试 运行 命令 response.css(".hero-name::text").extract() 但返回了一个空括号.
我已采取的步骤
scrapy shell 'https://msf.gg/characters'
>>> response.css(".hero-name::text").extract()
[] 返回空括号。
我也试过 运行 xpath 和相同的结果
>>> response.xpath("/html/body/div[1]/section/div/div/ul/li[1]/div[3]/h4/text()").extract()
[]
首先,
你应该 scrapy shell 'https://msf.gg/characters'
而不是 scrapy shell 两次。
其次,
它是一个动态呈现的页面,即 JS 呈现的页面;
因此scrapy无法定位那些元素,你可以view(response)
看看; (这基本上就是 scrapy 看到的)
一个解决方案是使用requests-html or selenium