我是巴西人,所以我很抱歉英语不好。我开始学习python和如何使用scrapy,我试图从表中获取信息,但由于某些原因,我编写的函数返回“None”,如您所见:
调试:从<;200https://gol.gg/teams/list/season-ALL/split-ALL/tournament-CBLOL%20Split%201%202020/>{'teste':无}
我试图在response.css中输入的任何类都返回“None”。我还试着从其他网站上用同样的代码获取一条文本,结果成功了,所以我猜这是关于这个网站的,但我真的不知道。有人能帮我拿一下吗
以下是我编写的代码:
import scrapy
class QuotesSpider(scrapy.Spider):
name = "equipes"
start_urls = ['https://gol.gg/teams/list/season-ALL/split-ALL/tournament-CBLOL%20Split%201%202020/']
def parse(self, response):
yield {'teste': response.css('tbody tr td.tablesaw-cell-persist').get()}
你的想法是正确的。数据是在javaScript的帮助下动态生成的。如果您在浏览器中禁用javaScript并转到下拉列表并尝试更改表名,那么您将看到它永远不会像“CBLOL Split 1 2020”更改为“CBLOL Academy Split 2 2021”不会改变,这个行为被称为动态填充javaScript数据,因为您没有通过获取静态HTML来获取数据。这就是为什么你需要无头浏览器来获取数据。事实上,我们无法修复一种技术来刮取一个站点,而不是,一个站点向我们展示了我们必须使用什么技术来刮取一个站点。在这里我使用
Selenium with Scrapy
,它也像刮痧蜘蛛一样超级快速我的代码:
输出:
相关问题 更多 >
编程相关推荐