網(wǎng)頁爬蟲 - python 爬蟲怎么處理json內(nèi)容
問題描述
看不清的話 網(wǎng)站地址是http://www.sse.com.cn/disclos...紅字是我需要的內(nèi)容 但是我提取不出來求教怎么操作
問題解答
回答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. html5 - css3scale和rotate同時(shí)使用轉(zhuǎn)換成matrix寫法該如何轉(zhuǎn)換?2. win10 python3.5 matplotlib使用報(bào)錯(cuò)3. php多任務(wù)倒計(jì)時(shí)求助4. css - 如何把一個(gè)視圖放在左浮動(dòng)定位的視圖的上面?5. javascript - jquery怎么讓a標(biāo)簽跳轉(zhuǎn)后保持tab的樣式6. MySQL的聯(lián)合查詢[union]有什么實(shí)際的用處7. javascript - vue組件的重復(fù)調(diào)用8. javascript - 小demo:請(qǐng)教怎么做出類似于水滴不斷擴(kuò)張的效果?9. python的正則怎么同時(shí)匹配兩個(gè)不同結(jié)果?10. javascript - axios請(qǐng)求回來的數(shù)據(jù)組件無法進(jìn)行綁定渲染
