python - pygooglevoice 登录问题

标签 python google-voice

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

或者,如果有人有关于彻底卸载 pygooglevoice for windows 的分步建议(以确保我获得所有文件),我将非常感激。

最佳答案

我制作了一个当前可用的克隆(至少用于发送 SMS 消息):http://code.google.com/r/kkleidal-pygooglevoiceupdate/

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

关于python - pygooglevoice 登录问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17354166/

相关文章:

python - 如何在代码中实现除数函数?

google-voice - 无需手机号码即可申请谷歌语音号码

javascript - 如何使用xpath从用 Angular 编写的网页中提取文本?

python - 使用 python 清除或删除 csv 中的第二列

python - 从 Groupby 创建新的 Pandas 列并划分其他列

python - Pandas 按多列分组时组合键

java - 未找到 Google Voice Java API 客户端登录

google-voice - 有谷歌语音API吗?

python - 使用多列的 Pandas groupby 函数