網(wǎng)頁(yè)爬蟲(chóng) - python 爬蟲(chóng)怎么處理json內(nèi)容
問(wèn)題描述
看不清的話 網(wǎng)站地址是http://www.sse.com.cn/disclos...紅字是我需要的內(nèi)容 但是我提取不出來(lái)求教怎么操作
問(wèn)題解答
回答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
相關(guān)文章:
1. 數(shù)組按鍵值封裝!2. java - 阿里的開(kāi)發(fā)手冊(cè)中為什么禁用map來(lái)作為查詢的接受類?3. docker不顯示端口映射呢?4. html5 - 使用echarts中的圖表 一個(gè)頁(yè)面導(dǎo)入了好幾個(gè)js圖表 實(shí)現(xiàn)echarts圖表隨著瀏覽器窗口變化而變化時(shí)出現(xiàn)了問(wèn)題5. javascript - 使用vue官方腳手架進(jìn)行單元測(cè)試,如何覆蓋到watch里的變量?6. python - django 使用 redirect 跳轉(zhuǎn)網(wǎng)頁(yè),怎么傳遞 referer 給目標(biāo)網(wǎng)頁(yè)7. python 3.4 error: Microsoft Visual C++ 10.0 is required8. python - 如何找第三方編譯好的模塊?9. python - SQLAlchemy 向?qū)?yīng)的id插入數(shù)據(jù)怎么操作?10. javascript - 為什么創(chuàng)建多行多列的表格最后只有一行內(nèi)有表格
