簡體   English   中英

Python IMAPlib錯誤10060

[英]Python IMAPlib ErrNo 10060

我正在編寫一個腳本,以從Web應用程序發出的電子郵件中獲取鏈接,然后啟動一組自動化測試。 目前,我的代碼只應該抓住電子郵件的正文,但我還沒有開始掃描其中的鏈接,因為我沒有得到任何回報。

import imaplib

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('user', 'passwd')
mail.list()
mail.select("inbox")

result, data = mail.search(None, "ALL")

ids = data[0]
id_list = ids.split()
latest_email_id = id_list[-1]

result, data = mail.fetch(latest_email_id, "(RFC822)")

raw_email = data[0][1]
print raw_email

我沒有在代碼中看到任何錯誤來獲取最新的電子郵件(收件箱頂部),並且為該帳戶設置了IMAP。 任何人都可以啟發我為什么會出錯:

socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

提前致謝。

編輯:公司防火牆阻止端口143和993(默認IMAP(S)端口),我已將解決方法作為答案。 我的代碼沒有錯!

為了解決公司的端口限制,我在終端中使用以下命令使用netsh命令將開放端口轉發到端口993(imaplib的SSL的默認設置)

netsh interface portproxy add v4tov4 listenport=UNBLOCKTHISPORT listenaddress=YOURIP connectport=THISPORTISOPEN connectaddress=YOURIP

Python:網址錯誤: <urlopen error [errno 10060]< div><div id="text_translate"><p> <strong>操作系統:Windows 7;</strong> <strong>Python 2.7.3 使用 Python GUI Shell</strong></p><p> 我正在嘗試通過 Python 閱讀一個網站,並且有幾個作者使用urllib和urllib2庫。 為了將站點存儲在變量中,我看到了一種類似的方法:</p><pre> import urllib import urllib2 g = "http://www.google.com/" read = urllib2.urlopen(g)</pre><p> 最后一行在 120 多秒后生成錯誤:</p><pre> > Traceback (most recent call last): File "<pyshell#27>", line 1, in > <module> > r = urllib2.urlopen(o) File "C:\Python27\lib\urllib2.py", line 126, in urlopen > return _opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 400, in open > response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 418, in _open > '_open', req) File "C:\Python27\lib\urllib2.py", line 378, in _call_chain > result = func(*args) File "C:\Python27\lib\urllib2.py", line 1207, in http_open > return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1177, in do_open > raise URLError(err) URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly > respond after a period of time, or established connection failed > because connected host has failed to respond></pre><p> 我嘗試繞過g變量並嘗試urlopen("http://www.google.com/")也沒有成功(它在相同的時間長度后生成相同的錯誤)。</p></div></urlopen>

[英]Python: URLError: <urlopen error [Errno 10060]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 Python SMTP Errno 10060 python套接字Errno 10060 python urlopen 錯誤 [Errno 10060] Errno 10060 Python通過gmail發送電子郵件 Python:網址錯誤: <urlopen error [errno 10060]< div><div id="text_translate"><p> <strong>操作系統:Windows 7;</strong> <strong>Python 2.7.3 使用 Python GUI Shell</strong></p><p> 我正在嘗試通過 Python 閱讀一個網站,並且有幾個作者使用urllib和urllib2庫。 為了將站點存儲在變量中,我看到了一種類似的方法:</p><pre> import urllib import urllib2 g = "http://www.google.com/" read = urllib2.urlopen(g)</pre><p> 最后一行在 120 多秒后生成錯誤:</p><pre> > Traceback (most recent call last): File "<pyshell#27>", line 1, in > <module> > r = urllib2.urlopen(o) File "C:\Python27\lib\urllib2.py", line 126, in urlopen > return _opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 400, in open > response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 418, in _open > '_open', req) File "C:\Python27\lib\urllib2.py", line 378, in _call_chain > result = func(*args) File "C:\Python27\lib\urllib2.py", line 1207, in http_open > return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1177, in do_open > raise URLError(err) URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly > respond after a period of time, or established connection failed > because connected host has failed to respond></pre><p> 我嘗試繞過g變量並嘗試urlopen("http://www.google.com/")也沒有成功(它在相同的時間長度后生成相同的錯誤)。</p></div></urlopen> Python urlopen IOError:[Errno socket錯誤] [Errno 10060] 針對套接字錯誤Errno 10060的Python try / except語句 [Errno 10060]偶爾發送電子郵件的Python腳本失敗 socket.error:[Errno 10060]使用Python發送電子郵件時 Python:urllib2.URLError:
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM