web主机上python脚本的问题

web主机上python脚本的问题,python,hosting,pywikibot,Python,Hosting,Pywikibot,我为Wikipedia编写了一个脚本&它在我的计算机上运行良好,但当我将它上载到我的web主机(Dreamhost)时,它不起作用&说我试图登录的用户被阻止了。这不是真的,它在我的计算机上运行&我没有被阻止。 这正是我收到的错误信息- A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

我为Wikipedia编写了一个脚本&它在我的计算机上运行良好,但当我将它上载到我的web主机(Dreamhost)时,它不起作用&说我试图登录的用户被阻止了。这不是真的,它在我的计算机上运行&我没有被阻止。 这正是我收到的错误信息-

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /home/tris1601/thewikipediaforum.com/pywikipedia/wikitest.py
   35 site = wikipedia.getSite()
   36 newpage = wikipedia.Page(site, u"User:Dottydotdot/test")
   37 newpage.put(text + "<br><br>'''Imported from [http://en.wikiquote.org '''Wikiquote'''] by [[User:DottyQuoteBot|'''DottyQuoteBot''']]", u"Testing")
   38 
   39 wikipedia.stopme()
newpage = Page{[[User:Dottydotdot/test]]}, newpage.put = <bound method Page.put of Page{[[User:Dottydotdot/test]]}>, text = u'You have so many things in the background that y... could possibly work?" <p> [[Ward Cunningham]] \n'
 /home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py in put(self=Page{[[User:Dottydotdot/test]]}, newtext=u"You have so many things in the background that y...''] by [[User:DottyQuoteBot|'''DottyQuoteBot''']]", comment=u'Testing', watchArticle=None, minorEdit=True, force=False, sysop=False, botflag=True)
 1380 
 1381         # Check blocks
 1382         self.site().checkBlocks(sysop = sysop)
 1383 
 1384         # Determine if we are allowed to edit
self = Page{[[User:Dottydotdot/test]]}, self.site = <bound method Page.site of Page{[[User:Dottydotdot/test]]}>, ).checkBlocks undefined, sysop = False
 /home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py in checkBlocks(self=wikipedia:en, sysop=False)
 4457         if self._isBlocked[index]:
 4458             # User blocked
 4459             raise UserBlocked('User is blocked in site %s' % self)
 4460 
 4461     def isBlocked(self, sysop = False):
global UserBlocked = <class wikipedia.UserBlocked>, self = wikipedia:en
UserBlocked: User is blocked in site wikipedia:en 
      args = ('User is blocked in site wikipedia:en',)
Python脚本中出现问题。下面是导致错误的函数调用序列,按发生顺序排列。
/home/tris1601/thewikipediaforum.com/pywikipedia/wikitest.py
35 site=wikipedia.getSite()
36 newpage=wikipedia.Page(站点,u“用户:Dottydotdot/test”)
37 newpage.put(文本+“

””从导入[http://en.wikiquote.org “'Wikiquote'”]由[[用户:DottyQuoteBot |“'DottyQuoteBot'”]],u“测试”) 38 39 wikipedia.stopme() newpage=Page{[[User:Dottydotdot/test]]},newpage.put=,text=u'你的背景中有很多东西,以至于。。。可能有用吗?“[[Ward Cunningham]]\n” /home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py-in-put(self=Page{[[User:Dottydotdot/test]},newtext=u“你的背景中有太多东西了,以至于你……。”]by[[User:DottyQuoteBot.''DottyQuoteBot']],comment=u'Testing',watchArticle=None,minorEdit=True,force=False,sysop=False,botflag=True) 1380 1381#检查块 1382 self.site()检查块(sysop=sysop) 1383 1384#确定是否允许我们编辑 self=Page{[[User:Dottydotdot/test]]},self.site=,)。未定义检查块,sysop=False /home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py在复选框中(self=wikipedia:en,sysop=False) 4457如果自身被阻止[索引]: 4458#用户被阻止 4459 raise UserBlocked('用户在站点%s“%self”中被阻止) 4460 4461 def被阻止(self,sysop=False): 全局UserBlocked=,self=wikipedia:en UserBlocked:用户在站点wikipedia:en中被阻止 args=('User is blocked in site wikipedia:en',)
你知道为什么它不起作用吗


谢谢,非常感谢!

可能是您的主机(Dreamhost)被阻止了,而不是您的用户。

我首先要添加一些调试。您能否捕获发送到wikipedia的输出以及它重新返回的结果?其中可能有更多的信息,您可以提取这些信息以了解失败的原因

[编辑]r.e.调试-考虑到您提供的小片段,很难给出建议。事实上,您在一个文件中有超过3.5k行,这表明其中存在一些相当不高效的编码,或者问题没有得到很好的解决……这可能会使调试更加棘手

话虽如此,上面调试中提到的.put()几乎肯定会向服务器发送请求。您可以从打印这些请求或请求的位开始。要尝试拼凑发送的请求,然后尝试只执行这些请求,并使用python的print命令记录输出:

print "Sending '%s' to server%(my_put_request)
…我的请求是你发送的数据位


[Edit2]我刚刚发现,这是您正在使用的pywikipedia机器人脚本。该机器人上的wikipedia文章支持Uggedal关于这是一个访问问题的建议。很有可能wikipedia识别了dreamhosts IP,而其他人过去曾尝试做过一些不好的事情,导致它们被阻止某种方式。

你真的应该添加一个.htaccess文件来限制人们列出你的目录内容[对不起,我对python很陌生,我该怎么做?干杯!