Re: [問題] 請教有關requests爬蟲問題

看板Python作者時間8年前 (2017/11/17 21:52), 8年前編輯推噓0(002)
留言2則, 1人參與, 8年前最新討論串2/2 (看更多)
s860134大: 請求檔頭: Host: shopee.tw User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0 Accept: application/json Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate, br Referer: https://shopee.tw/ctrltheworld x-csrftoken: EDzOC9CHtAxsPvGBS2KXTTJbKLUwiQrW content-type: application/json x-requested-with: XMLHttpRequest x-api-source: pc if-none-match-: 55b03-6dcab09663189d7151aacf7d8a6138a0 origin: https://shopee.tw Content-Length: 22 Cookie: sessionid=xflei4m1tk76gqoqwxem45nw3lhe0htg; __utma=88845529.1855994735.1511016359.1511016359.1511016359.1; __utmb=88845529.5.10.1511016359; __utmz=88845529.1511016359.1.1.utmcsr=tw.search.yahoo.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmt=1; appier_utmz=%7B%22csr%22%3A%22tw.search.yahoo.com%22%2C%22timestamp%22%3A1511016360%7D; _atrk_sync_cookie=true; _atrk_ssid=mSThOmIDlRq2p0hZq0hXgl; _atrk_sessidx=5; _atrk_siteuid=HPJPqvUmd6LFhB5W; _ga=GA1.2.1855994735.1511016359; _gid=GA1.2.90188106.1511016410; __BWfp=c1511016411186x3c855c285; SPC_IA=-1; SPC_EC=-; SPC_F=7GxDjIJPZA90xBQvGoOoe2kjH2FM1Qvm; REC_T_ID=50757676-cc6f-11e7-be2a-d09466042355; SPC_T_ID="2X0JcPGdCeceJszhTNPMJVFRURdMPUdJUX17alD8h0QkBXmPBcDB8Ovo5IzU73mLEPCXICL8ywy2RBQpNWKogAqwFnFKBznDF7g1TgtaLbU="; SPC_SI=7z1sz9s9rrkgy9cix3o8v38jf27y51w1; SPC_U=-; SPC_T_IV="jd0ZPGRxeWVgfAIZWK40hg=="; __utmc=88845529; django_language=zh-hant; SPC_SC_TK=; UYOMAPJWEMDGJ=; SPC_SC_UD=; csrftoken=EDzOC9CHtAxsPvGBS2KXTTJbKLUwiQrW; _gat=1 Connection: keep-alive 回應檔頭: server: nginx date: Sat, 18 Nov 2017 14:52:07 GMT content-type: application/json content-length: 1397 access-control-allow-headers: Content-Type,Authorization,X-Requested-With,X-CSRFToken,If-None-Match-,X-API-SOURCE content-encoding: gzip vary: Accept-Encoding, Cookie x-request-id: 6kwxAnZlHRv4fM68BDQrG3 etag: "630f134e595c977ce90ac22e01b6ba11;gzip" access-control-allow-credentials: true access-control-allow-origin: https://seller.shopee.tw access-control-allow-methods: POST,GET,OPTIONS,PUT,DELETE set-cookie: SPC_SI=7z1sz9s9rrkgy9cix3o8v38jf27y51w1; Domain=.shopee.tw; expires=Sun, 19-Nov-2017 14:52:07 GMT; httponly; Max-Age=86400; Path=/ X-Firefox-Spdy: h2 ※ 編輯: ntasop (106.104.97.172), 11/18/2017 23:24:12

11/19 10:56, 8年前 , 1F
你code不是有header,把請求檔頭完整抄上去的好了吧
11/19 10:56, 1F

11/19 19:04, 8年前 , 2F
記得把 Content-Length: 22 移掉,requests 會幫你加
11/19 19:04, 2F
文章代碼(AID): #1Q3kcEtj (Python)
文章代碼(AID): #1Q3kcEtj (Python)