利用Python模拟登录pastebin.com的实现方法
import requests
from lxml import etree
# 登录 https://pastebin.com/
login_url = "https://pastebin.com/login"
username = "kuang123321"
password = "xxxxxx"
api_dev_key = "4f45a996aa78079d8f7d14f104c45893"
session = requests.Session()
form_data = {
"submit_hidden": "submit_hidden",
"user_name": username,
"user_password": password,
"submit": "Login"
}
headers = {"content-type": "application/x-www-form-urlencoded"}
res = session.post(login_url, data=form_data, headers=headers)
print(res.status_code, res.url)
# 获取 api_dev_key
api_url = "https://pastebin.com/api"
text = session.get(api_url).content.decode("utf-8")
html = etree.HTML(text)
target_divs = html.xpath('//*[@id="content_left"]/div[9]/div/text()')
if target_divs:
api_dev_key = target_divs[0]
print(api_dev_key)
else:
raise Exception("cannot find api_dev_key")
- vivos12pro值得入手吗?vivos12pro参数配置优缺点详细评测
- Weverse(追星互动)最新版 v2.18.1 安卓中文版
- C++实现景区旅游信息管理系统
- win10怎么关闭defender图标 win10关闭defender图标方法
- cf辅助最新版(CF窗口化工具) v1.6 官方免费版
- adsafe(广告拦截软件) v3.0.1.1010 安卓手机版
- 天天酷跑怎么刷钻石_天天酷跑最新版钻石获得方法介绍说明
- Win10 PC创意者更新15063慢速预览版修复更新已知问题汇总
- 嗨格式录屏大师 v3.69.0.4 免费安装版
- windows xp系统资源不足无法完成api问题分析及解决