You have several problems:
- the url should be
http://www.whoscored.com/stageplayerstatfeed
- wrong
GET
parameters
- missing important required headers
- you need
response.json()
, not response.body
The fixed version:
import requests
url = 'http://www.whoscored.com/stageplayerstatfeed'
params = {
'field': '1',
'isAscending': 'false',
'orderBy': 'Rating',
'playerId': '-1',
'stageId': '9155',
'teamId': '32'
}
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
'Host': 'www.whoscored.com',
'Referer': 'http://www.whoscored.com/Teams/32/'}
response = requests.get(url, params=params, headers=headers)
fixtures = response.json()
print fixtures
Prints:
[
{
u'AccurateCrosses': 0,
u'AccurateLongBalls': 10,
u'AccuratePasses': 89,
u'AccurateThroughBalls': 0,
u'AerialLost': 2,
u'AerialWon': 4,
...
},
...
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…