我有一個應用程序,我在我的手機上發送帖子請求並獲取一些信息。我試圖模仿來自Python腳本的發佈請求,並獲取相同的響應。在Python中模仿發佈請求
我用了一個數據包嗅探器,看看該請求是什麼:
POST /b/ss/wdgwespmaflm/0/JAVA-4.10.0-AN/s23376784 HTTP/1.1
connection: close
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Linux; U; Android 5.1; en-US; HTC One_M8 Build/LMY47O.H4)
Accept-Language: en-US
Content-Length: 530
Host: w88.espn.com
Accept-Encoding: gzip
ndh=1&ce=UTF-8&vid=5f2c4950ca6e9359&pev2=ADBINTERNAL%3ALifecycle&c.&a.&DaysSinceFirstUse=52&RunMode=Application&HourOfDay=12&Resolution=1080x1776&DaysSinceLastUse=0&CarrierName=Partner&AppID=ESPN%20Fantasy%205.1.1%20%28155%29&TimeSinceLaunch=3&OSVersion=Android%205.1&PrevSessionLength=17&Launches=73&DeviceName=HTC%20One_M8&DayOfWeek=7&LaunchEvent=LaunchEvent&internalaction=Lifecycle&.a&.c&t=00%2F00%2F0000%2000%3A00%3A00%200%20-120&mid=61999711066602377445137974387884905365&pe=lnk_o&pageName=ESPN%20Fantasy%205.1.1%20%28155%29
我使用的模塊requests
,我想這
r = requests.post("http://w88.espn.com/b/ss/wdgwespmaflm/0/JAVA-4.10.0-AN/s23376784", headers={
'connection': 'close',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Linux; U; Android 5.1; en-US; HTC One_M8 Build/LMY47O.H4)',
'Accept-Language': 'en-US',
'Content-Length': '530',
'Host': 'w88.espn.com',
'Accept-Encoding': 'gzip'})
但腳本只是被卡住的要求。我在哪裏發送內容? 我是不是應該把它作爲headers
發送?我試過data
,它也沒有工作。
有什麼想法?
首先,您的網址是不是完成「/b/ss/wdgwespmaflm/0/JAVA-4.10.0-AN/s23376784」,缺少協議和主機。 –
使用'http:// w88.espn.com/b/ss/wdgwespmaflm/0/JAVA-4.10.0-AN/s23376784'作爲'URL' – Andersson
嗯好吧,我會試試 – Mumfordwiz