我正在尝试通过“单击”查看新邮件“来刮取邮件。如果您想测试此收件箱,只需向以下地址发送电子邮件:“发件人:”Yopmail。但是,我只看到“[]”作为我的结果。我做错了什么?“[]”是什么意思?这是我的密码:
import requests
from bs4 import BeautifulSoup
# Start the session
session = requests.Session()
# Create the payload
payload = {'login':'1cdsjsdjkdfsnjsdfj42@yopmail.com',
}
# Post the payload to the site to log in
s = session.post("http://www.yopmail.com/en/", data=payload)
# Navigate to the next page and scrape the data
s = session.get('http://www.yopmail.com/en/')
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml' )
message = soup.find_all('div', class_='pdet nb')
print(message)
首先,
[]
的意思是没有找到任何divs
与这个特定的类有一件事我认为可能是问题在于,你使用的是来自
request.get(url)
的响应,而不是来自session.get(...)
。我想如果您只使用request.get()
,您可能无法登录。 解决办法是使用soup = BeautifulSoup(s.text, 'lxml' )
但是如果这不起作用,错误可能是该类实际上没有
div
尝试一步一步地打印每个变量的结果,以确保正确获取数据
可能会有一些问题,比如
可能无法获取数据 第页上没有div 无特定类别的div(pdet nb) 登录错误
请尝试打印soup变量以确保提取数据。如果未提取,请后退一步进行检查
相关问题 更多 >
编程相关推荐