googlevoice不会以编程方式登录(Python) [英] googlevoice will not programmatically login (Python)

查看:140
本文介绍了googlevoice不会以编程方式登录(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的程序尝试登录到GoogleVoice(from googlevoice import Voice, util)来发送SMS消息时,我得到了以下错误回溯.

I am getting the following error traceback when my program tries to login to GoogleVoice (from googlevoice import Voice, util) to send SMS message.

    File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\MainFrame.py", line 38, in call_mainframe
    ah.compare_status() # compares current status with historical status. alerts alarm team if necessary
  File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\alarm_handler.py", line 61, in compare_status
    self.megaphone = megaphone.MegaPhone()     # Am I going to have problems putting this here? I am getting relentless login fails due to the shitty googlevoice login
  File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\megaphone.py", line 18, in __init__
    self.voice.login(bl_google_credentials[0], bl_google_credentials[1])
  File "C:\Python27\lib\site-packages\googlevoice\voice.py", line 70, in login
    galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)

AttributeError: 'NoneType' object has no attribute 'group'

我的程序在过去的几周中已经成功运行.每隔一段时间,就会抛出上述错误,并且错误处理将再次尝试.现在,它已经有数百次尝试没有成功登录.

My program has been running successfully for the last several weeks. Every once in a while, the above error would get thrown and the error handling would just try again. Now, it has not had a successful login in several hundred tries.

我认为可能很重要的一个问题是,无论是否发送SMS,程序每十(10)分钟登录一次(罕见的情况下,最多每隔几天发送一次).

One issue that I feel may be important is that the program was logging in every ten (10) minutes regardless of whether or not an SMS was sent (rare case, every few days at most).

在上述回溯中,您可以看到仅在需要时将执行GoogleVoice登录的函数调用移到了循环中.它仍然有问题,因为需要发送警报通知.

In the above traceback, You can see that I moved the function call that performed the GoogleVoice login to within the loop only in case its needed. It is still having problems because there is an alarm notification that needs to be sent out.

我尝试登录和注销我的Google帐户,无济于事.

I tried logging in and out of my Google account, no avail.

这是一个线索->以下代码是从追溯的最后一行(错误源)中标识的文件中复制出来的:

Here's a clue --> the following code was copied out of the file identified in the last line of the traceback (source of error):

def login(self, email=None, passwd=None):
        """
        Login to the service using your Google Voice account
        Credentials will be prompted for if not given as args or in the ``~/.gvoice`` config file
        """
        if hasattr(self, '_special') and getattr(self, '_special'):
            return self

    if email is None:
        email = config.email
    if email is None:
        email = input('Email address: ')

    if passwd is None:
        passwd = config.password
    if passwd is None:
        from getpass import getpass
        passwd = getpass()

    content = self.__do_page('login').read()
    # holy hackjob
    galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
    self.__do_page('login', {'Email': email, 'Passwd': passwd, 'GALX': galx})

    del email, passwd

    try:
        assert self.special
    except (AssertionError, AttributeError):
        raise LoginError

    return self

我们应该注意

galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)

是错误的根源,并且(很重要)错误的上一行显示

is the source of the error and that (this is important) the line immediately above it says

# holy hackjob

推荐答案

我已经能够解决此问题.看来Google确实做了修改:

I have been able to correct the issue. It appears that Google did make a modification:

此修补程序在这里: http://pastebin.com/bxvNjj00

或者您可以简单地修改voice.py并将以galx =开头的冒犯行更改为此:

Or you can simply modify voice.py and change the offending line that begins with galx = to this:

galx = re.search(r"name = \" GALX \"type = \" hidden \"\ n * value = \"(.+)\",content).group(1)

galx = re.search(r"name=\"GALX\" type=\"hidden\"\n *value=\"(.+)\"", content).group(1)

这篇关于googlevoice不会以编程方式登录(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆