使用Python登录到具有使用Requests.Session的Ajax弹出式登录页面的网站

使用Python登录到具有使用Requests.Session的Ajax弹出式登录页面的网站,python,ajax,web-crawler,python-requests,Python,Ajax,Web Crawler,Python Requests,我试图从www.mutualart.com收集一些数据,但是,该网站有一个Ajax登录表单,通过单击“登录”弹出。因此,当我尝试使用Requests会话的post方法登录此网站时,它不起作用 要从该网站获取高级数据,我需要登录该网站并维护cookie以访问我需要的信息 在这种情况下,如何使用post方法登录网站 import requests from lxml import htmlfrom bs4 import BeautifulSoup import sys

我试图从www.mutualart.com收集一些数据,但是,该网站有一个Ajax登录表单,通过单击“登录”弹出。因此,当我尝试使用Requests会话的post方法登录此网站时,它不起作用

要从该网站获取高级数据,我需要登录该网站并维护cookie以访问我需要的信息

在这种情况下,如何使用post方法登录网站

    import requests
    from lxml import htmlfrom bs4 import BeautifulSoup
    import sys

    EMAIL = ''
    PASSWORD = ''

    MainUrl = 'https://www.mutualart.com'


    payload = {
        'email': EMAIL,
        'txtUserPassword': PASSWORD
    }

    with requests.Session() as s:

        login_req = s.post(MainUrl, data=login_data)

        url = 'https://www.mutualart.com/Artwork/Vue-de-Franche-Comte/9CDD9A00EE80E8C9'

        post_one = s.get(url)
        soup = BeautifulSoup(post_one.text, 'lxml')

        estimate = soup.find_all('div',class_='v2__artwork-detail__price-col')
        name = soup.find_all('div', class_ = 'v2__artwork-detail__section')

        print estimate #This should be the data that can be accessed by premium subscription
        print login_req.status_code #The connection seems to be there

我可以使用下面的url在中访问我的凭据 “MainUrl”的位置

''

Chrome的“开发工具”在查看与网站相关的网络活动时非常方便()。在“网络”选项卡中,确保正在录制并切换“保留日志”


旁注:为了我目前的声誉,我无法回复评论,我觉得这更适合我的回复。

非常感谢,我会尝试一下!