网页爬虫 - 求高手python爬虫:对扫描二维码的模拟登录问题
迷茫
迷茫 2017-04-18 09:06:16
0
2
727

微信网页版登录需要扫描二维码,做Python爬虫的时候该如何模拟这个过程?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
阿神

First of all, you need to know python and packet capture and analysis

刘奇

Rough steps:

  • Get the URL of this QR code image from the webpage (using PhantomJS)

  • Download this image using URL (Python)

  • Save images to your phone (ssh/adb)

  • Access the method of parsing QR codes through WeChat on your mobile phone, and send this image (automated testing framework for android/ios)

Supplement: Why can’t the PC side be completed independently?

The QR code of the WeChat web version is equivalent to generating a Key for the current browser. When the WeChat mobile client is logged in, ​​it can obtain this Key by scanning the code and tell the WeChat server that the Key is this. The logged in user, therefore the PC browser is authorized to access the chat interface.

This process is completed by WeChat mobile terminal and WeChat server. It cannot be solved by parsing the QR code through Python.

In addition, the QR code we see from the browser is like this:

<img class="img" mm-src="https://login.weixin.qq.com/qrcode/Ie8OIBZqJQ==" mm-src-load="qrcodeLoad" mm-src-parallel="" mm-src-timeout="10" mm-src-retry-count="2" src="https://login.weixin.qq.com/qrcode/Ie8OIBZqJQ==">

The HTML obtained by Python using requests or urllib is like this:

<img class="img" mm-src="{{qrcodeUrl}}"  mm-src-load="qrcodeLoad" mm-src-parallel mm-src-timeout="10" mm-src-retry-count="2" src="https://res.wx.qq.com/zh_CN/htmledition/v2/images/img2e4e03.gif">

This one{{qrcodeUrl}} needs to execute js to generate, so I wrote above to use PhantomJS to get this page, and then give the image to Python.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!