pywikipedia login.py socket.error:(10060,'Operation timed out')

时间:2009-09-02 15:03:35

标签: python mediawiki pywikibot

我对python完全不熟悉,所以如果我做了明显错误的事情,希望有人可以提供帮助。我正在尝试在词汇表.referata.com上创建并运行一个简单的pywikipedia bot,这是一个语义mediawiki站点。我下载了pywikipedia发行版并创建了一个家庭文件:

import config, family, urllib         # REQUIRED

class Family(family.Family):          # REQUIRED
    def __init__(self):               # REQUIRED
        family.Family.__init__(self)  # REQUIRED
        self.name = 'explicator'        # REQUIRED; replace with actual name

        self.langs = {                # REQUIRED
            'en': 'vocabularies.referata.com',  # Include one line for each wiki in family
        }

我创建了一个用户wikibot并运行:

python generate_user_files.py

根据以下说明:

http://meta.wikimedia.org/wiki/Using_the_python_wikipediabot

当我尝试跑步时:

python login.py

我收到以下错误:

C:\pywikipedia>python login.py
Password for user wikibot on explicator:en:
Logging in to explicator:en as wikibot
Traceback (most recent call last):
  File "login.py", line 376, in <module>
    main()
  File "login.py", line 372, in main
    loginMan.login()
  File "login.py", line 261, in login
    cookiedata = self.getCookie(api)
  File "login.py", line 178, in getCookie
    response, data = self.site.postData(address, self.site.urlEncode(predata))
  File "C:\pywikipedia\wikipedia.py", line 4915, in postData
    conn.endheaders()
  File "C:\Python25\lib\httplib.py", line 860, in endheaders
    self._send_output()
  File "C:\Python25\lib\httplib.py", line 732, in _send_output
    self.send(msg)
  File "C:\Python25\lib\httplib.py", line 699, in send
    self.connect()
  File "C:\Python25\lib\httplib.py", line 683, in connect
    raise socket.error, msg
socket.error: (10060, 'Operation timed out')

他们的东西是愚蠢/明显我需要检查或做错了吗?我在防火墙后面,这会是问题吗? (如果是这样,我需要采取哪些步骤来解决它)。

感谢您的帮助 斯图尔特

2 个答案:

答案 0 :(得分:0)

我不熟悉w / pywikipedia = p,但问题至少是关于连接而不是python:套接字连接无法在开始时建立。

  • login.py L178中的帖子网址address是否正确?任何拼写错误或配置错误?
  • 网址是否可访问?您可以尝试直接访问浏览器中的URL并查看是否有任何http响应。如果服务器可以访问,您可以通过netstat -antnetstat -anptcp或类似方式检查它是否正在侦听特定端口,如80。在Windows上,具有默认设置的防火墙可能会阻止通信,您可以查看是否有任何警告对话框等待确认,或检查fireware日志。此外,您需要具有管理员权限才能使用端口80。

答案 1 :(得分:0)

对我有用,对不起。我刚刚创建了一个帐户,并使用了您的家庭档案。它似乎就在你身边。

$ python login.py -v -v -family:explicator -lang:en
Pywikipediabot [http] trunk/pywikipedia (r6858, May 08 2009, 15:23:29)
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3]
WARNING: Using -v -v on login.py might leak private data. When sharing, please double check your password is not readable and log out your bots session.
Password for user NicDumZ on explicator:en: 
Logging in to explicator:en as NicDumZ
self.site.postData(/w/index.php?title=Special:Userlogin&useskin=monobook&action=submit, wpSkipCookieCheck=1&wpPassword=XXXXX&wpDomain=&wpRemember=1&wpLoginattempt=Aanmelden%20%26%20Inschrijven&wpName=NicDumZ)
302/Found
Date: Thu, 03 Sep 2009 19:46:47 GMT
Server: Apache
Cache-Control: private, must-revalidate, max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: referata_session=XXXXXXXXXXdab8c53151d27046d68473; path=/; HttpOnly
Set-Cookie: referataUserID=4; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Set-Cookie: referataUserName=NicDumZ; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Set-Cookie: referatasession=XXXXXXXXXX270504613b1d26dfef82e6; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Vary: Accept-Encoding,Cookie
X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=referataToken;string-contains=referataLoggedOut;string-contains=referata_session
Location: http://vocabularies.referata.com/wiki/Main_Page
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8


Should be logged in now

你能尝试使用-v -v选项,以便我可以帮助你调试这个问题吗?请回复评论,以便我获取您的更新。