将Python请求与生成器电子邮件站点一起使用

2024-10-01 15:44:14 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用以下http代码从generator.email站点获取链接时,总是会出现此错误

requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

这是我试过的代码

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Accept-Language': 'en-US,en;q=0.9',
}
cookies = {'surl':'6jorge19753f@timjarrett.net'}
email = '6jorge19753f@timjarrett.net'
url = f'https://generator.email/{email}'
# url = 'https://generator.email/ '
print(url)
response = requests.get(url, headers=headers, cookies=cookies)
print(response.content)
quit()

我如何解决这个问题?我尝试了使用和不使用标题和cookies,但都不起作用


Tags: 代码imageurlnetapplicationemailresponsexml
1条回答
网友
1楼 · 发布于 2024-10-01 15:44:14
import requests
start_url="https://generator.email/"
page_data=requests.get(start_url)
print(page_data.content)

这给了输出正确,我没有张贴的输出,因为它是非常长的

print(page_data)

输出

<Response [200]>

这意味着请求已成功发送

将电子邮件id添加到开始url时,它给出了错误

raise RemoteDisconnected("Remote end closed connection without"
                                         " response")
#many lines were there have not copied the entire thing though but this is the main problem

要查看有关此错误的更多信息,请查看此链接 Python HTTP Server/Client: Remote end closed connection without response error

相关问题 更多 >

    热门问题