web主机上python脚本的问题

2024-10-02 00:38:36 发布

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

我为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',)

你知道为什么它不起作用吗?在

谢谢,非常感谢!在


Tags: theintestselffalseputispage
2条回答

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

我先添加一些调试。你能捕获你发送到wikipedia的输出及其返回的结果吗?可能还有更多的信息,你可以提取出来看看为什么失败了。在

[Edit]r.e.调试-很难给出你提供的小片段建议。在一个文件中有超过3.5k行的事实表明,其中要么有一些相当低效的编码,要么问题没有特别好地分解。。。这可能会使调试更加棘手。在

尽管如此,上面的调试中提到的.put()几乎可以肯定是在向服务器发送一个请求。你可以先打印出这些请求或请求的一部分。要尝试拼凑发送的请求,然后尝试仅执行这些请求并使用python的print命令记录输出:

print "Sending '%s' to server%(my_put_request)

…我的请求是你发送的数据位。在

[Edit2]我刚刚发现这是你使用的pywikipedia机器人脚本。wikipedia上关于bot mentions some points on permissions的文章,它支持uggedals关于它是一个访问问题的建议。很有可能维基百科承认dreamhosts IP,而其他人在过去曾尝试做过一些不好的事情,导致他们在某种程度上被屏蔽。在

相关问题 更多 >

    热门问题