Experimenting with direct-dial
authorEd Page <eopage@byu.net>
Mon, 19 Jul 2010 23:06:49 +0000 (18:06 -0500)
committerEd Page <eopage@byu.net>
Mon, 19 Jul 2010 23:06:49 +0000 (18:06 -0500)
hand_tests/test_directdial.py [new file with mode: 0755]
src/backends/browser_emu.py

diff --git a/hand_tests/test_directdial.py b/hand_tests/test_directdial.py
new file mode 100755 (executable)
index 0000000..ace20d3
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import sys
+import logging
+
+
+_moduleLogger = logging.getLogger(__name__)
+sys.path.insert(0,"../src")
+
+import backends.gvoice
+
+
+def main(username, password, number):
+       gvoice = backends.gvoice.GVoiceBackend()
+       gvoice.login(username, password)
+       gvoice._browser.USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16"
+       page = gvoice._browser.download("https://www.google.com/voice/m/x?m=call&n=18004664411&f=&v=6", {})
+       print page
+
+
+if __name__ == "__main__":
+       args = sys.argv[1:]
+       main(args[0], args[1], "")
index b676a13..6092398 100644 (file)
@@ -36,8 +36,19 @@ _moduleLogger = logging.getLogger(__name__)
 socket.setdefaulttimeout(45)
 
 
+def add_proxy(protocol, url, port):
+       proxyInfo = "%s:%s" % (url, port)
+       proxy = urllib2.ProxyHandler(
+               {protocol: proxyInfo}
+       )
+       opener = urllib2.build_opener(proxy)
+       urllib2.install_opener(opener)
+
+
 class MozillaEmulator(object):
 
+       USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729)'
+
        def __init__(self, trycount = 1):
                """Create a new MozillaEmulator object.
 
@@ -154,8 +165,7 @@ class MozillaEmulator(object):
                        redirector
                )
                u.addheaders = [(
-                       'User-Agent',
-                       'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729)'
+                       'User-Agent', self.USER_AGENT
                )]
                if not postdata is None:
                        req.add_data(postdata)