Simple analog login for WAP version of Sina Weibo

Source: Internet
Author: User

Environment: Ubuntu 16.04

Python version 3.5+

Importrequests, lxml fromBs4ImportBeautifulSoup fromIoImportBytesio fromPILImportImageclasssimulationlogging:#Construct Data    defStructure_data (self): Data= {            'Remember':' on',            'Backurl':'http://weibo.cn/1786213845/fans?vt=4',            'Backtitle':'Micro Blog',            'Trycount':"',            'Submit':'Login'} URL='http://weibo.cn/1786213845/fans?vt=4'I=requests.get (URL). Text R= BeautifulSoup (I,"lxml") url_2='http://login.weibo.cn/login/'Url_login= url_2 + str (r.find ('form', method="Post"). Get ('Action')) Password_name= R.find ('input', type="Password"). Get ('name') Username= Input ('Please enter user name:') data['Mobile'] =Username Password= Input ('Please enter your password') Data[password_name]=Password VKS= R.find_all ('input') data['VK'] = Vks[7].get ('value') data['Capid'] = Vks[8].get ('value') img= R.find ('img', alt="Please open the picture display"). Get ('src') file=Bytesio (Requests.get (IMG). Content) img=image.open (file) img.show () code= Input ('Please enter the verification code shown (not case-sensitive)') data['Code'] =Code Img.close () self.get_content (url_login, data)#get Web page content    defget_content (self, Url_login, data): Request= Requests.post (Url_login, Data=data). Text R= BeautifulSoup (Request,"lxml")        Print(R)if __name__=='__main__': Test=simulationlogging () test.structure_data ( )

Simple analog login for WAP version of Sina Weibo

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.