2

我正在进行一项实验,我正在通过电子邮件/短信向一大群受试者发送标准消息,然后通过电子邮件/短信接收他们的回复。要添加短信功能,我想使用 pygooglevoice。当我使用空闲界面时,我可以正常登录。但是当我运行一个示例脚本时,它会抛出“登录错误”。我已经实现了此处列出的修复(替换 URL pygooglevoice 访问):Pygooglevoice login error

我正在运行的示例脚本:

from googlevoice import Voice  
import sys  
import BeautifulSoup  



 def extractsms(htmlsms) :
     """
     extractsms  --  extract SMS messages from BeautifulSoup tree of Google Voice SMS HTML.

     Output is a list of dictionaries, one per message.
     """
     msgitems = []  # accum message items here
     #  Extract all conversations by searching for a DIV with an ID at top level.
     tree = BeautifulSoup.BeautifulSoup(htmlsms)  # parse HTML into tree
     conversations = tree.findAll("div",attrs={"id" : True},recursive=False)
     for conversation in conversations :
         #  For each conversation, extract each row, which is one SMS message.
         rows = conversation.findAll(attrs={"class" : "gc-message-sms-row"})
         for row in rows :  # for all rows
             #  For each row, which is one message, extract all the fields.
             msgitem = {"id" : conversation["id"]}  # tag this message with conversation ID
             spans = row.findAll("span",attrs={"class" : True}, recursive=False)
             for span in spans :  # for all spans in row
                 cl = span["class"].replace('gc-message-sms-', '')
                 msgitem[cl] = (" ".join(span.findAll(text=True))).strip()  # put text in dict
             msgitems.append(msgitem)  # add msg dictionary to list
     return msgitems

 voice = Voice() 
 voice.login('MY_GV_USERNAME','MY_GV_PASSWORD')

 voice.sms() for msg in extractsms(voice.sms.html):
 print str(msg)

错误:

> File "build\bdist.win32\egg\googlevoice\voice.py", line 78, in login
>     raise LoginError LoginError

或者,如果有人对 Windows 的 pygooglevoice 的干净卸载有分步建议(以确保我获得所有文件),我将不胜感激。

4

1 回答 1

1

我做了一个当前有效的克隆(至少用于发送短信): http ://code.google.com/r/kkleidal-pygooglevoiceupdate/

问题是 Google 更改了登录 URL。此外,我在 POST 请求中添加了一些参数,这可能有助于解决在 POST 请求中遇到的一些问题。登录现在应该可以顺利进行。

于 2013-11-24T02:54:08.460 回答