我正在使用請求庫來執行GET請求。我可以得到一個200響應,但它不返回任何數據,它返回對象的'作業',但沒有別的。我正在使用Visualping.io api。我已經成功地運行CURL命令,並從瀏覽器URL成功運行....這是我的Python代碼。我編輯了我的憑據和PHP sesh id。Python請求獲取(URL)200響應,無數據
`import requests
r = requests.get("https://visualping.io/api/job/list", headers={'username':'[email protected]', 'password':'MyPassword', 'User-Agent':'test'})
print (r.content)
print (r.status_code)
print (r.headers)
print (r.json)`
我自己也嘗試沒有用戶,並通過頁眉,和剛剛過去的他們在這樣的網址..再次,這工作從瀏覽器和捲曲
`https://visualping.io/api/job/list?username='myusername'&password='mypassword'`
對於這兩個,我得到以下輸出
// printcontent { 「成功」:真正的 「工作」:[]}
//打印狀態碼200
//下面是打印頁眉
{'X-Powered-By':'PHP/5.5.35','Transfer-Encoding':'chunked','Set-Cookie':'PHPSESSID = {MYSESSIONID }; expires = Fri,26-May-2017 20:42:31 GMT;最大年齡= 3600; '''Expires':'Thu,19 Nov 1981 08:52:00 GMT','Vary':'Accept-Encoding','Server':'nginx','Connection':'keep-alive' ,'Pragma':'no-cache','Cache-Control':'no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0','Date':'Fri, 26 May 2017 19:42:31 GMT','Content-Type':'text/html','Content-Encoding':'gzip'}
// This is print json {u'jobs': [],u'success':TRUE}
這在一個塊
`{"success":true,"jobs":[]}
200
{'X-Powered-By': 'PHP/5.5.35', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'PHPSESSID={MYSESSIONID}; expires=Fri, 26-May-2017 20:43:47 GMT; Max-Age=3600; path=/', 'Expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'Vary': 'Accept-Encoding', 'Server': 'nginx', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'Date': 'Fri, 26 May 2017 19:43:47 GMT', 'Content-Type': 'text/html', 'Content-Encoding': 'gzip'}
<bound method Response.json of <Response [200]>>`
https://company-32327.frontify.com/d/Lr7wNKb1omxI/visualping-api
下面是從文檔 GET/API /工作/列表
`{
"jobs": {
"active": [
{
"id": "NzqkVe1AI6WYBli",
"created": "2015-09-06 00:37:16",
"url": "www.google.de",
"description": "Google Landing Page",
"runs": "10",
"trigger": "1",
"interval": "60",
}
],
"inactive": [
{
"id": "gCXHiydaCulFOFA",
"created": "2016-09-06 00:37:16",
"url": "www.bing.de",
"description": "Bing Landing Page",
"runs": "25",
"trigger": "10",
"interval": "300"
}
],
}
}`
更新:通過沒有憑據產生相同的結果「成功」:true,「jobs」:[]} {'X-Powered-By':'PHP/5.5.35','Transfer-Encoding':'chunked ','Set-Cookie':'PHPSESSID = 9aq0m56d1otm617hoidnl40np4; expires = Fri,26-May-2017 21:12:55 GMT;最大年齡= 3600; '''Expires':'Thu,19 Nov 1981 08:52:00 GMT','Vary':'Accept-Encoding','Server':'nginx','Connection':'keep-alive' ,'Pragma':'no-cache','Cache-Control':'no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0','Date':'Fri, 26 May 2017 20:12:55 GMT','Content-Type':'text/html','Content-Encoding':'gzip'} – Goldfish