我试图用scrapy刮掉一些NBA数据,但我无法弄清楚如何从动态生成的表中获取数据 .
例如,我无法通过xpaths到达表中的数据http://stats.nba.com/game/0041700404/ . 我需要的数据似乎是动态加载的表,我无法弄清楚如何获取http://stats.nba.com/stats/boxscoresummaryv2?GameID=0041700404中的数据,其中包含我需要的json格式的数据 .
我尝试连接到网站并打印json:
import scrapy
import json
class DataSpider(scrapy.Spider):
name = "test2"
start_urls = [
'http://stats.nba.com/stats/boxscoresummaryv2?GameID=0041700404',
]
def parse(self, response):
print(json.loads(response.body))