我正在尝试使用以下网站中的脚本登录:https://interpals.net/app/auth/login 我的代码如下
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from requests import Session
from bs4 import BeautifulSoup as bs
with Session() as s:
site = s.get("https://interpals.net/app/auth/login")
bs_content = bs(site.content, "html.parser")
token = bs_content.find("input", {"name":"csrf_token"})["value"]
login_data = {"username":"user","password":"pass'", "csrf_token":token}
s.post("https://interpals.net/app/auth/login",login_data)
home_page = s.get("https://interpals.net/pm.php")
我的第一个麻烦是,当我写参数“ html.parser”时,我没有得到正确的解析器,实际上,我什至没有获得正确的html,这就是我得到的
https://paste.fedoraproject.org/paste/K1SCjKBG7CAigUH4GX7qUQ
当我将“ html.parser”更改为“ lxml”或“ html5lib”时,我确实得到了HTML表单,这就是
https://paste.fedoraproject.org/paste/4w-AT20kTIXoAmgsPmpqIQ
但是,在最后一个中,我找不到输入csrf_token所需要的登录名,有人可以提供建议吗?