我想从www.mutualart.com网站但是,该网站有一个Ajax登录表单,通过单击“登录”弹出。因此,当我试图使用Requests Session的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”的位置。在
'https://www.mutualart.com/Ajax/LogIn/UserControlLogin'
Chrome的“开发工具”在查看与网站相关的网络活动时非常有用(https://developer.chrome.com/devtools)。在“网络”选项卡中,确保正在录制并切换“保留日志”。在
旁注:对我目前的声誉我无法回复评论,我觉得这更适合我的回应。在
相关问题 更多 >
编程相关推荐