Python 使用BeautifulSoup解析网站时出现问题

Python 使用BeautifulSoup解析网站时出现问题,python,parsing,beautifulsoup,Python,Parsing,Beautifulsoup,我正在尝试使用网站中的脚本登录: 我的代码如下 #! /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,

我正在尝试使用网站中的脚本登录: 我的代码如下

#! /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,这就是我得到的

当我将“html.parser”更改为“lxml”或“html5lib”时,我得到的确实是一个html表单,如下所示


然而,在最后一个例子中,我没有找到我登录所需的输入csrf_标记,任何人都可以给出建议,请?

您希望在html解析字符串中使用csrf标记吗?是的,我想要输入的值,因为在网站的html控制台中存在找到您希望使用
获取值的输入标记。查找(FILTER).get('value')
但是应该提交正确的输入?@Tserenjamts这就是我在代码上所做的,实际上从你的html中我找不到带有
name='csrf\u标记'
的输入,你写错了吗