5

python爬虫无法获取app端数据

TOKEN 获取
post :
header:release=1
body:{"device_id":"iPhone7,2_0_BFF903C0-3611-4004-8F00-29D83398D8BC"}

url:
https://bestvapi.bestv.cn/app/init?anm=BesTV&app=ios&bn=Apple&channelid=721a8fb9-0990-4217-b73f-3904d6155e91&idfa=BFF903C0-3611-4004-8F00-29D83398D8BC&lct=0.000000,0.000000&lt=1&mn=iPhone&mnc=46000&net=wifi&os=9.3.4&pnm=com.bestv.app.BesTV&rs=750x1334&timestamp=1471424785&ua=Mozilla/5.0(iPhone;CPUiPhoneOS9_3_4likeMacOSX)AppleWebKit/601.1.46(KHTML,likeGecko)Mobile/13G35&ut=idfa&signature=7a0c2c2ead715e1ce81899d60012529940696112bbef45633c4455c868c9bc5e

上面这个我用下面这个方法为何不能获得?

-*- coding: cp936 -*-

import urllib
import urllib2
import json

data={"device_id":"iPhone7,2_0_BFF903C0-3611-4004-8F00-29D83398D8BC"}

data1 = urllib.urlencode(data)

header={'content-type': 'application/json',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0',
'release':'1'}
url='https://bestvapi.bestv.cn/app/init?anm=BesTV&app=ios&bn=Apple&channelid=721a8fb9-0990-4217-b73f-3904d6155e91&idfa=BFF903C0-3611-4004-8F00-29D83398D8BC&lct=0.000000,0.000000&lt=1&mn=iPhone&mnc=46000&net=wifi&os=9.3.4&pnm=com.bestv.app.BesTV&rs=750x1334&timestamp=1471424785&ua=Mozilla/5.0(iPhone;CPUiPhoneOS9_3_4likeMacOSX)AppleWebKit/601.1.46(KHTML,likeGecko)Mobile/13G35&ut=idfa&signature=7a0c2c2ead715e1ce81899d60012529940696112bbef45633c4455c868c9bc5e'

req = urllib2.Request(url = url,data=data1,headers=header)

#print req

res_data = urllib2.urlopen(req)

res = res_data.read()

html=json.loads(res)

返回的错误说device id不能为空
但我的data里面不是有一个device_id吗?

查看全部
yinghua_shu
yinghua_shu
2016/08/23 01:48
  • 点赞
  • 收藏
  • 回答
    私信

2个回复