鱼C论坛

 找回密码
 立即注册
查看: 2292|回复: 1

[已解决]爬东方财富网问题

[复制链接]
发表于 2022-10-28 16:13:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
url=f'http://1.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112409400485999513473_1666888866635&pn=1&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1666888866749'
   
resp=requests.get(url=url,headers=herader).text


返回的数据没法转换为json格式
最佳答案
2022-10-29 00:43:12
  1. import requests
  2. import re
  3. import json

  4. url = 'http://1.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112409400485999513473_1666888866635&pn=1&pz=20&po=1&' \
  5.       'np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80&' \
  6.       'fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,' \
  7.       'f128,f136,f115,f152&_=1666888866749'
  8. headers = {'user-agent': 'mozilla'}
  9. r = requests.get(url=url, headers=headers)
  10. d = json.loads(re.findall(r'\((.*?)\);', r.text)[0])
  11. print(type(d))
  12. print(d)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-10-29 00:43:12 | 显示全部楼层    本楼为最佳答案   
  1. import requests
  2. import re
  3. import json

  4. url = 'http://1.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112409400485999513473_1666888866635&pn=1&pz=20&po=1&' \
  5.       'np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80&' \
  6.       'fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,' \
  7.       'f128,f136,f115,f152&_=1666888866749'
  8. headers = {'user-agent': 'mozilla'}
  9. r = requests.get(url=url, headers=headers)
  10. d = json.loads(re.findall(r'\((.*?)\);', r.text)[0])
  11. print(type(d))
  12. print(d)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-20 16:09

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表