网页爬虫 - python 爬虫怎么处理json内容
问题描述


看不清的话 网站地址是http://www.sse.com.cn/disclos...红字是我需要的内容 但是我提取不出来求教怎么操作
问题解答
回答1:import requestsurl = ’http://query.sse.com.cn/commonSoaQuery.do?siteId=28&sqlId=BS_GGLL&extGGLX=&stockcode=&channelId=10743%2C10744%2C10012&extGGDL=&order=createTime%7Cdesc%2Cstockcode%7Casc&isPagination=true&pageHelp.pageSize=15&pageHelp.pageNo=1&pageHelp.beginPage=1&pageHelp.cacheSize=1&pageHelp.endPage=5’headers = { ’Referer’:’http://www.sse.com.cn/disclosure/credibility/supervision/inquiries/’, ’User-Agent’:’Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36’}r = requests.get(url, headers=headers)print r.json()[’result’]回答2:
import requestsurl = ’http://query.sse.com.cn/commonSoaQuery.do?siteId=28&sqlId=BS_GGLL&extGGLX=&stockcode=&channelId=10743%2C10744%2C10012&extGGDL=&order=createTime%7Cdesc%2Cstockcode%7Casc&isPagination=true&pageHelp.pageSize=15&pageHelp.pageNo=1&pageHelp.beginPage=1&pageHelp.cacheSize=1&pageHelp.endPage=5&_=1498029409382’session = requests.session()session.headers.update({ ’Referer’: ’http://www.sse.com.cn/disclosure/credibility/supervision/inquiries/’, ’User-Agent’: ’Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36’})result = session.get(url).json()print result
相关文章:
1. windows-7 - win7下使用cmder,如何设置vim的tab为4个空格?2. python 多进程 或者 多线程下如何高效的同步数据?3. python - 怎么进行服务器性能分析4. web - nginx location 搜索算法问题!?5. thinkPHP5中获取数据库数据后默认选中下拉框的值,传递到后台消失不见。有图有代码,希望有人帮忙6. mysql - 要取出数据库中按某字段排序后的前10,20,30条数据要怎么做?7. java - socket类服务端如何防止被ddos攻击?8. Java中的多人游戏。将客户端(玩家)连接到其他客户端创建的游戏9. MySQL的SELECT...FOR UPDATE究竟起什么作用10. android - 重写onTouch方法,如何通过判断自定义view的某个属性值来返回不同的返回值

网公网安备