ezoic

Thursday, March 8, 2018

Can one use tools to simulate logon by python script?

Can one use tools to simulate logon by python script?

I once saw some ppl use tools to simulate logon by python scripts. I was not sure if it would work. So I tried one script I found. And it works. Here is the script.

# -*- coding:utf-8 -*-import requests
from bs4 import BeautifulSoup
import urllib
import re

url =  'https://accounts.douban.com/login'data={
    'redir': 'https://www.douban.com/',
    'form_email':'XXXXXX',
    'form_password':'XXXXXX',
    'login':u'登录'}
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'}
r = requests.post(url, data, headers=headers)
page = r.text

soup = BeautifulSoup(page,"html.parser")
print(soup)

It was written in Python 3.6. And the headers does not matter. I put a random headers. 
I got what I wanted. 

No comments:

Post a Comment

looking for a man

 I am a mid aged woman.  I was born in 1980. I do not have any kid. no complicated  dating before . I am looking for a man here for marriage...