【发布时间】:2017-08-30 19:43:33
【问题描述】:
我正在尝试在此链接中抓取网站:
https://www.whoscored.com/Players/11119/Show/Lionel-Messi
我想从摘要、防御、进攻选项卡中获取数据,我尝试过 这个:
import requests
# This is the json data link i wish to get from the defensive tab (from developer tools)
url = "https://www.whoscored.com/StatisticsFeed/1/GetPlayerStatistics?category=summary&subcategory=defensive&statsAccumulationType=0&isCurrent=true&playerId=11119&teamIds=&matchId=&stageId=&tournamentOptions=&sortBy=Rating&sortAscending=&age=&ageComparisonType=&appearances=&appearancesComparisonType=&field=Overall&nationality=&positionOptions=&timeOfTheGameEnd=&timeOfTheGameStart=&isMinApp=false&page=&includeZeroValues=true&numberOfPlayersToPick="
response = requests.get(url)
print(response.json())
我无法打印 json 数据并从选项卡中抓取我需要的数据,我做错了什么吗? 感谢您的帮助。
【问题讨论】:
-
该 URL 无效,至少如本问题所述,无效。
-
响应是 HTML,而不是 JSON,所以这是行不通的。
标签: python json web-scraping python-requests scraper