我正在进行一项实验,我正在通过电子邮件/短信向一大群受试者发送标准消息,然后通过电子邮件/短信接收他们的回复。要添加短信功能,我想使用 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 的干净卸载有分步建议(以确保我获得所有文件),我将不胜感激。