前几天在群里看别人说有的post取不到数据,有人发了个例子,我看了下代码还挺规则清晰的。收藏了。
import console; import inet.whttp; import zlib; function myfun(){ var url = "https://www.douyu.com/japi/activepointnc/api/feedShark"; var headers = { ['Host'] = 'www.douyu.com'; ['Accept'] = 'application/json, text/plain, */*'; ['Origin'] = 'https://www.douyu.com'; ['X-Requested-With'] = 'XMLHttpRequest'; ['Content-Type'] = 'application/x-www-form-urlencoded'; ['Accept-Encoding'] = 'gzip, deflate, br'; ['Accept-Language'] = 'zh-CN,zh;q=0.9'; ['Cookie'] = 'dy_did=659654738dfd11573f3f23bc00031501; acf_did=659654738dfd11573f3f23bc00031501; smidV2=20190809205013bc7aab8509a58c7b46c4bbc49d12269200983c9c8ef482370; loginrefer=pt_cjkjhjelmkkd; _dys_refer_action_code=init_page_studio_v; Hm_lvt_e99aee90ec1b2106afe7ec3b199020a7=1570515570,1570516951,1570698963,1570723564; PHPSESSID=nhfal6lqj8pc0kfpmftq7q9060; acf_auth=b1c8k%2FSiiG7xiqZY4bwrko5JX7nFF5dCl7gPniLDAElfdIPoQ%2FFk5jCD4fG2qjIpZBC3Eo1pLF7UIZcZAApn6ZdBvvdGndV99GcYVhoGX9ndz93Xgz6YRtI; wan_auth37wan=77972f3a0060DmEQ4MCi4hGX%2BV5fsyedA0Q1o%2BxPMpr9Ejhf6QfWJ%2FJbTojSV6%2FDFtypZEM5jrwIgRL%2B6TQXIdhAk73uwafOudmh6LKKm4erwiHc2q8; acf_uid=247748077; acf_username=247748077; acf_nickname=CsereOr; acf_own_room=0; acf_groupid=1; acf_phonestatus=0; acf_avatar=https%3A%2F%2Fapic.douyucdn.cn%2Fupload%2Favatar%2Fdefault%2F01_; acf_ct=0; acf_ltkid=58833522; acf_biz=1; acf_stk=4614241b174b5fa3; Hm_lpvt_e99aee90ec1b2106afe7ec3b199020a7=1570723862; acf_ccn=6f58472289e8d833f9f902293b3b680e'; } var ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"; var referer = "https://www.douyu.com/1080583"; var post_data = "rid=1080583&point=10&type=0&ctn=6f58472289e8d833f9f902293b3b680e"; var http=inet.whttp(ua); var html,err,errCode = http.post(url,post_data,headers,referer); return html; } console.log(myfun()); console.pause(true);其实post数据这块,也可以直接用数组然后转换一下的。