发送post请求,进行网站登录

Magiclala的博客 / 2024-02-26 / 原文

发送post请求,进行网站登录

import requests

# 请求头
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
    'Referer': 'https://passport.17k.com/login/index.html'
}

# 携带post的表单数据
data = {
    'loginName': '17323035232',
    'password': 'sadxl1232232'
}
url = 'https://passport.17k.com/ck/user/login'
response = requests.post(url, headers=headers, data=data)
print(response.text)