I am working on an experiment where I am emailing/texting a large group of subjects a standard message and then receiving their responses via email/text. To add texting functionality I want to use pygooglevoice. When I use the Idle interface I'm able to login fine. But when I run an example script, it throws the "login error". I have already implemented the fix listed here (replacing the URL pygooglevoice accesses): Pygooglevoice login error.
The example script I'm running:
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)
The Error:
> File "build\bdist.win32\egg\googlevoice\voice.py", line 78, in login
> raise LoginError LoginError
Alternatively, if someone has step-by-step advice for a clean uninstall of pygooglevoice for windows (to make sure I get all of the files), I would really appreciate it.