Idle boredom ...
A bunch of online, just practiced hand (mostly novice)
# Coding=utf-8
Import requests
From BS4 import BeautifulSoup
headers = {
' User-agent ': ' mozilla/5.0 (Windows NT 6.1; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/56.0.2924.87 safari/537.36 ',
' Origin ': ' https://www.php.cn ',
' Referer ': ' Https://www.php.cn/signin ',
' Host ': ' www.php.cn ',
}
s = requests. Session ()
r = S.get (' Https://www.php.cn/signin ', headers=headers)
Soup = BeautifulSoup (r.content, "Html.parser")
#获取登录数据
once = soup.find (' input ', {' name ': ' Once '}) [' Value ']
Name = Soup.find (' input ', {' type ': ' Text ', ' class ': ' SL '}) [' Name ']
Password = soup.find (' input ', {' type ': ' Password ', ' class ': ' SL '}) [' Name ']
Login_data = {
Name: ' xxx ',
Password: ' xxx ',
' Once ': once,
' Next ': '/'
}
#登录
S.post (' Https://www.php.cn/signin ', Login_data, headers=headers)