我在尝试thaat发送邮件的脚本时遇到以下错误
import urllib.request
import re
import smtplib
from email.mime.text import MIMEText
from bs4 import BeautifulSoup
page=urllib.request.urlopen("http://www.crummy.com/")
soup=BeautifulSoup(page)
v=soup.findAll('a',href=re.compile('http://www.crummy.com/2012/07/24/0'))
for link in v:
w=link.get('href')
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'xxxxxxxxxxx', 'xxxxxxx' )
server.sendmail( 'xxxxxxxxx', 'xxxxxxxxx', "bonus question is up" )
Traceback (most recent call last): File "C:\Python32\bonus", line 14,
in server = smtplib.SMTP( "smtp.gmail.com", 587 ) File
"C:\Python32\lib\smtplib.py", line 259, in init File "C:\Python32\lib\smtplib.py", line 319, in connect self.sock = self._get_socket(host, port, self.timeout) File "C:\Python32 \lib\smtplib.py", line 294, in _get_socket return socket.create_connection((host, port), timeout) File "C:\Python32\lib\socket.py", line 386, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno 11004] getaddrinfo failed plse advice on the best way to go round it
getaddrinfo
函数有以下用途:如果失败,则意味着它无法将给定的主机名转换为相应的地址。它实际上是在做一个DNS查询。
由
getaddrinfo
返回的错误号“11004”与此消息关联:似乎您正在查找的名称没有与之关联的正确数据。
你确定你的网址是正确的吗?
链接:
getaddrinfo
:http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspxWinSock错误代码:http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
相关问题 更多 >
编程相关推荐