使用Python ping Pingomatic (XMLRPC) 时出错

1 投票
1 回答
1057 浏览
提问于 2025-04-16 08:28

我正在尝试用Python给Pingomatic发送一个“ping”。

我写了这个代码:

import xmlrpclib

print "START"

s = xmlrpclib.Server('http://rpc.pingomatic.com')
reply = s.weblogUpdates.ping('Test','http://www.testblog.com')

print "END"

但是当我运行的时候,出现了这个错误:

>>> 
START

Traceback (most recent call last):
  File "C:/xxxxxxxxxxxxxxxxxx/pingtest1.py", line 6, in <module>
    reply = j.weblogUpdates.ping('Test','http://www.testblog.com')
  File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1570, in __request
    verbose=self.__verbose
  File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "C:\Python27\lib\xmlrpclib.py", line 1462, in parse_response
    p.feed(data)
  File "C:\Python27\lib\xmlrpclib.py", line 557, in feed
    self._parser.Parse(data, 0)
ExpatError: syntax error: line 1, column 0
>>> 

我该怎么解决这个问题呢?

谢谢。

1 个回答

1

原来这是Pingomatic的回复格式出了问题。我试着给Weblogs.com发送了请求,结果一切正常。

我给Automattic发了邮件告诉他们这个情况,他们已经修复了这个问题——现在一切都应该正常了!

撰写回答