search

Home  >  Q&A  >  body text

Web crawler - python crawls websites and parses non-json content

I just learned to get json content, but the website I crawled today does not return json content, and a random number is generated after each request link

I don’t know if it will affect the content I want to crawl

The content that needs to be obtained is the content in the middle of the picture below


Website link http://www.szse.cn/main/discl...

Code I tried myself:

import requests

dir = '/Users/S1Lence/Desktop/new_html/szse/许可类重组问询函'

headers = {'Host': 'www.szse.cn',
       'Referer': 'http://www.szse.cn/main/disclosure/jgxxgk/wxhj/',
       'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36'
       }
payload= {'ACTIONID': '7',          
       'AJAX': 'AJAX-TRUE',
      'CATALOGID': 'main_wxhj',
      'TABKEY': 'tab1',
      'selecthjlb': '许可类重组问询函',
      'tab1PAGENO': '1',
      'tab1PAGECOUNT': '7',
      'tab1RECORDCOUNT': '63',
      'REPORT_ACTION': 'navigate'}
res = requests.post('http://www.szse.cn/szseWeb/FrontControllere', data=payload)
print(res.text)

The output content is not what I want. How to climb

学习ing学习ing2745 days ago1131

reply all(2)I'll reply

  • 黄舟

    黄舟2017-06-28 09:28:28

    Copy his header information and use it. .

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-28 09:28:28

    The url address of your post is wrong, it should be

    http://www.szse.cn/szseWeb/FrontController.szse

    reply
    0
  • Cancelreply