-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwireutils.py
More file actions
38 lines (31 loc) · 1.63 KB
/
wireutils.py
File metadata and controls
38 lines (31 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Copyright @ 2009, Waverz.com - BSD license - Information wants to be free!
# misc utilities
import logging
def webrequest(method, host, url, headers, payload):
"""Request an HTTPS page, either via the appengine api, or using httplib"""
import urllib
def fetch_urllib2(method, host, url, headers, payload):
"""use urllib2 to fetch a wave"""
import httplib
connection = httplib.HTTPSConnection(host)
connection.request(method, url, payload, headers)
http_response = connection.getresponse()
http_data = http_response.read()
connection.close()
return http_data
print method+" "+host+url
if (isinstance(payload, dict)):
payload = urllib.urlencode(payload)
if ((method == "POST")) & (not ("Content-Type" in headers)):
headers['Content-Type'] = 'application/x-www-form-urlencoded'
if not ("User-Agent" in headers):
headers['User-Agent'] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/4.0.249.11 Safari/525.13"
return fetch_urllib2(method,host,url,headers,payload)
if (__name__ == "__main__"):
session = "503282974482375274562"
cookie = "DQAAAI8AAADqGuAdyCS0oaSk8PE4FDZZUl_KCmr0Gj6AVICpeE9WScTxIjM5CJLrNI23neGAQtXEDs51NkaLaxoik-IRUyLxwpzwa5Q3sUeRJ9Xo1Zh-6bpZlckaS242zuacV_Fk7qLULp2JRf1I5YbFalpolOU2_BzyBenDi9pf_22hhBJWQwXWm9c4YYQOlynF2fLI08Q"
waveid = "googlewave.com!w+fkvUXIemA"
print webrequest("GET", "wave.google.com", "/wave/wfe/fetch/"+waveid+"/"+session+"?v=3",
{'Cookie': "WAVE="+cookie}, None)