Re: [問題] 初學爬蟲post問題

看板Python作者 (魯)時間8年前 (2017/06/19 05:46), 8年前編輯推噓2(201)
留言3則, 2人參與, 最新討論串2/2 (看更多)
import requests import json payload = {"danhao": "50586414310"} headers = {"X-AjaxPro-Method": "SearchKuaidi"} url = "http://ht.sldexpress.com/ajaxpro/crm.Select,crm.ashx" resp = requests.post(url, data=json.dumps(payload), headers= headers) print(resp.text) Python3.5測試以上ok ※ 引述《japing (上進心)》之銘言: : 要爬的網站http://ht.sldexpress.com/Search.htm?winzoom=1 : 主要是輸入單號後 可以抓取重量的資訊 : 已經透過開發工具找出 是用post方式傳送資料 : 但我照著送只會回覆 response 200 : 有爬文過利用偽裝瀏覽器的方式送資料一樣回覆空白的資訊 : 想請教是否我POST送出的指令有誤呢? : http://imgur.com/a/sYOdo 此為我找到要post的資料 : 程式碼如下 : import requests : payload = {'danhao': '550586414310'} : resp = requests.\ : post('http://ht.sldexpress.com/ajaxpro/crm.Select,crm.ashx', \ : data=payload) : print resp : 麻煩各位指點一下了 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 112.104.26.8 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1497822378.A.A95.html ※ 編輯: jn8029 (112.104.26.8), 06/19/2017 05:48:34

06/19 10:58, , 1F
太感謝了,有看到關鍵字,努力學習去@@
06/19 10:58, 1F

06/19 11:51, , 2F
我也是用postman測到底那個header要灌進去才有反應的XD
06/19 11:51, 2F

06/19 19:07, , 3F
瞭解~原來有這個超級好物@@
06/19 19:07, 3F
文章代碼(AID): #1PHlIggL (Python)
討論串 (同標題文章)
文章代碼(AID): #1PHlIggL (Python)