python requests 爬虫, 解析 jsonrpc 失败, 请高手帮帮忙. 我用 firefox 的 httpfox 能看到回复了很大一串数据, get 头部是按照 httpfox 中完全照抄的.

2016-09-05 17:50:13 +08:00
 icy20088
代码:
import requests
from bs4 import BeautifulSoup

myPost={"version":"1.1","method":"PmData.getDataSet","params":[[{"operation":"fetchpm","filter_starttime":"","filter_endtime":"","filter_extendtime":"","base_time":"","select_counters":"auto","filter_string":"nodename='BB1_C050E_C00323OD_BALOK'","prefix_class":0,"select_time":"total","base_object":"object","select_object":"nodename"},{"operation":"evalformula","formulasource":"all","formulafile":"etijian/etijian_New_BB","formulas":["C01_Data_CSSR","C02_RRC_Setup_Success_Rate","C03_RRC_Connection_Setup_SR_Service","C04_ERAB_Call_Setup_Success_Rate","C05_CSFB_Setup_Success_Rate","C06_eRAB_Drop_Call_Rate","C07_DL_Packet_Loss_Rate","C08_UL_Packet_Loss_Rate","C09_Intra_LTE_Handover_Success_Rate","C10_Network_Availability_Cell_Level","C11_IRATHO_Success_Rate","C12_VolTe_CSSR"]},{"operation":"output","fields":["C01_Data_CSSR","C02_RRC_Setup_Success_Rate","C03_RRC_Connection_Setup_SR_Service","C04_ERAB_Call_Setup_Success_Rate","C05_CSFB_Setup_Success_Rate","C06_eRAB_Drop_Call_Rate","C07_DL_Packet_Loss_Rate","C08_UL_Packet_Loss_Rate","C09_Intra_LTE_Handover_Success_Rate","C10_Network_Availability_Cell_Level","C11_IRATHO_Success_Rate","C12_VolTe_CSSR"],"top":"","filter":"","sortexpr":"time,object"}],{"repeat_merge":"0","repeat_timeprefix":["TimeSer"],"repeat_timefilter":[{"time_display":"From 2016-08-29 00:00 to 2016-09-05 00:00","time_start":"7d","time_end":"","time_unit":"d","time_extend_filter":""}],"repeat_objectprefix":[],"repeat_objectfilter":[],"repeat_objectexpand":"0"}],"itkdebug":{"view":"/itk/web/views/itk_standard/pm_dynaview.xml","client":"itk-web-client-3.0.5-1"}}

myHder1={
"Host":"4g.coldice.me",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0",
"Accept":"application/json",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding":"gzip, deflate",
"Content-Type":"application/json; charset=UTF-8",
"Cookie":"itksession=5b4lj0Ai",
"Referer":"https://4g.coldice.me/itk/web/",
"Connection":"keep-alive",
"Pragma":"no-cache",
"Cache-Control":"no-cache"
}
myRep=requests.get("https://4g.coldice.me/itk/rpc",headers=myHder1,verify=False)

响应:
>>> myRep.text
'{"jsonrpc":"2.0","error":{"message":"Attempt to access RPC method using GET at /itk/rpc","code":"-32603"},"id":null}'
1863 次点击
所在节点    Python
2 条回复
lxy
2016-09-05 17:58:49 +08:00
那么你的 myPost 变量是用来做什么的呢?
icy20088
2016-09-05 18:02:16 +08:00
@lxy 我去,见笑了, 我应该用 Post, 多谢了! 哈哈~~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/304099

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX