模拟登录
网页登录方法一:
import requests
from bs4 import BeautifulSoup
def main():
resp = requests.get('http://github.com/login')
if resp.tatus.code != 200:
return
# 获取cookies
cookies = resp.cookies.get_dict()
soup = BeautifulSoup(resp.text, 'lxml')
# 获取第一个隐藏域
utf8_value = soup.select_one('form input[name=utf8]').attrs['value']
# 获取第二个隐藏域
authenticity_token_value = soup.select_one('form input[name=authenticity_token]').attrs['value']
data = {
'utf8': utf8_value,
'authenticity_token_value': auth