1. When I was crawling a web page, when I was dealing with data, I encountered a kind of dict type data, which I couldn"t handle. I tried a variety of methods, but I couldn"t find a solution. The
code is as follows:
def stock_parse ():
url = "https://static.howbuy.com/??/upload/auto/script/fund/jzzs_005235.js,/upload/auto/script/fund/jjjl_005235.js,/upload/auto/script/fund/data_005235.js?v=ad5292c"
response = requests.get(url)
rule = "gpzhListData = (.*);"
stocks = re.findall(rule,response.text)[0]
print(stocks)
according to what I said on the Internet, I changed single quotation marks into double quotation marks and tried to convert them to standard json format, but failed. What I said later is that my final data is not in standard json format, and a lot of data does not have single quotation marks, so it is still not possible to use third-party library demjson, results. Now it is the data I got.
{"lastDate":"2018-06-30th October 2018-06-30th: [{zqmc:" Haitian flavor industry", zqdm:"603288",zjbl:6.26,ccdb:18365}, {zqmc:" Kweichow Moutai", zqdm:"600519",zjbl:6.19,ccdb:2300}, {zqmc:" Yili shares", zqdm:"600887",zjbl:6.1,ccdb:67600}, {zqmc:" Wuliangye", zqdm:"000858",zjbl:6.02,ccdb:21500}, {zqmc:" Yanghe", zqdm:"002304",zjbl:5.92,ccdb:10500}, {zqmc:" Luzhou laojiao", zqdm:"000568",zjbl:5.89,ccdb:25600}, {zqmc:" Zhongju High-tech", zqdm:"600872",zjbl:5.1,ccdb:96898}, {zqmc:" Shuijingfang", zqdm:"600779",zjbl:4.97,ccdb:47800}, {zqmc:" Shanxi Fenjiu", zqdm:"600809",zjbl:4.6, Ccdb:11000}, {zqmc:" Kouzi cellar", zqdm:"603589",zjbl:4.59,ccdb:39700}], "2018-03-31 Qing: [{zqmc:" Shanxi Fenjiu", zqdm:"600809",zjbl:6.78,ccdb:27900}, {zqmc:" Haitian flavor industry", zqdm:"603288",zjbl:6.72,ccdb:26800}, {zqmc:" Guizhou Moutai", zqdm:"600519",zjbl:6.64,ccdb:2200}, {zqmc:" Luzhou laojiao", Zqdm:"000568",zjbl:6.47,ccdb:25800}, {zqmc:" Yanghe", zqdm:"002304",zjbl:6.39,ccdb:13400}, {zqmc:" Shuanghui Development", zqdm:"000895",zjbl:6.14,ccdb:54300}, {zqmc:" Yili", zqdm:"600887",zjbl:6.11,ccdb:48564}, {zqmc:" Wuliangye", zqdm:"000858",zjbl:6.04,ccdb:20600}, {zqmc:" give up the wine industry", zqdm:"600702",zjbl:6.0,ccdb:37960}, {zqmc:" Tsing Tao Beer", zqdm:"600600",zjbl:3.85,ccdb:21580}], "dateList": [" 2018-06-30,2018-03-31"], "cgjzdList": [{jsrq:"2018-06-30mm preceptive 60.37}, {jsrq:"2018-03-31ZD zqmc:" 64.87}]}
I really don"t know how to deal with this data format. I hope you can help solve it. I hope you"d better not use regular expressions, because it looks messy. I hope you can help solve it. Thank you.
related codes
/ / Please paste the code text below (do not replace the code with pictures)