python3使用requests实现模拟用户登录
程序员文章站
2022-05-01 21:44:23
...
import requests
userAgent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
header={
# "origin": "passport.mafengwo",
"Referer": "passport.mafengwo/",
'User-Agent': userAgent,
}
def mafengwoLogin(account, password):
# 模仿 登录
print ("开始模拟登录手游买号平台")
postUrl="passport.mafengwo/login/"
postData={
"passport": account,
"password": password,
}
responseRes=requests.post(postUrl, data=postData, headers=header)
# 无论是否登录成功,状态码一般都是 statusCode=200
print(f"statusCode={responseRes.status_code}")
print(f"text={responseRes.text}")
if __name__=="__main__":
# 从返回结果来看,有登录成功
mafengwoLogin("13756567832", "000000001")
推荐阅读