search

Home  >  Q&A  >  body text

linux - Python encounters verification problems when grabbing public account articles

Encountered verification problems when grabbing WeChat public account articles under Linux! ! ! ! ! ! ! !

This is the People’s Daily link I want to grab: http://mp.weixin.qq.com/profile?src=3×tamp=1492739045&ver=1&signature=bSSQMK1LY77M4O22qTi37cbhjhwNV7C9V4aor9HLhAvbGc2ybWX*qg3WqxntZ7iq0kvYe87oP pcSJKFdmGMx5g==
1: First of all, accessing on the browser is normal.
2: The access prompt under Linux requires verification. The following is a simple code

url = http://mp.weixin.qq.com/profile?src=3&timestamp=1492738883&ver=1&signature=bSSQMK1LY77M4O22qTi37cbhjhwNV7C9V4aor9HLhAvbGc2ybWX*qg3WqxntZ7iq2xTLUTfxAMzK79UGvalY1A==
response = urllib2.urlopen(url)
print response.read()

The results of the visit are as follows:

Additional explanation of how to obtain the link to the public account:
1: First visit the link: http://weixin.sogou.com/weixi...
2: Then obtain the link to the People's Daily public account. jump.

大家讲道理大家讲道理2749 days ago638

reply all(4)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 13:35:44

    Can it be captured without simulating the request header? It is recommended to simulate the request header first and try again

    reply
    0
  • 某草草

    某草草2017-05-16 13:35:44

    # coding: utf-8
    
    import requests
    
    headers = {}
    headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
    
    url = 'http://mp.weixin.qq.com/profile?src=3&timestamp=1492739045&ver=1&signature=bSSQMK1LY77M4O22qTi37cbhjhwNV7C9V4aor9HLhAvbGc2ybWX*qg3WqxntZ7iq0kvYe87oPpcSJKFdmGMx5g=='
    r = requests.get(url, headers=headers)
    print r.text

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 13:35:44

    Now after adding the header to the request, the error returned is as follows. Please give me some more tips

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-16 13:35:44

    You can use request, the local environment is Mac OSX, python3.6.1

    import requests
    
    headers = {'user-agent' : 'Mozilla/5.0'}
    respon = requests.get('http://mp.weixin.qq.com/profile?src=3&timestamp=1492831080&ver=1&signature=bSSQMK1LY77M4O22qTi37cbhjhwNV7C9V4aor9HLhAvbGc2ybWX*qg3WqxntZ7iqB7vsPUlOS3zhl-8n5FUODg==', headers = headers)
    respon.encoding = 'utf-8'
    print(respon.text)

    The content is in the line with the red box

    reply
    0
  • Cancelreply