Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating facebook webproxy with python
    text
    copied!<p>I'm trying to create webproxy for personal use to access facebook (it is often blocked from a few locations where I happen to spend some time). </p> <p>Started from this code: <a href="http://code.google.com/p/gevent/source/browse/examples/webproxy.py?name=1.0b2" rel="nofollow">http://code.google.com/p/gevent/source/browse/examples/webproxy.py?name=1.0b2</a></p> <p>I've modified it to work with the cookies replacing urllib with requests in the following way:</p> <pre><code>def proxy_post(path, env, proxy_url, start_response): if '://' not in path: path = 'http://' + path try: #response = br.submit(path, env) response = requests.post(path, params = env) print '%s: %s' % (path, response) headers = [(k, v) for (k, v) in response.headers.items() if k not in drop_headers] scheme, netloc, path, params, query, fragment = urlparse(path) host = (scheme or 'http') + '://' + netloc except Exception, ex: sys.stderr.write('error while reading %s:\n' % path) traceback.print_exc() tb = traceback.format_exc() error_str = escape(str(ex) or ex.__class__.__name__ or 'Error') return ['&lt;h1&gt;%s&lt;/h1&gt;&lt;h2&gt;%s&lt;/h2&gt;&lt;pre&gt;%s&lt;/pre&gt;' % (error_str, escape(path), escape(tb))] else: start_response('%s OK' % response.status_code, headers) data = response.content data = fix_links(data, proxy_url, host) return [data] </code></pre> <p>But when I try to login I've got the following error:</p> <pre><code>Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gevent/wsgi.py", line 116, in handle self.data.extend(result) TypeError: 'NoneType' object is not iterable &lt;WSGIServer fileno=3 address=0.0.0.0:8088&gt;: Failed to handle request: request = &lt;http_request "POST /https://www.facebook.com/login.php?login_attempt=1 HTTP/1.1" 127.0.0.1:56381&gt; application = &lt;function application at 0x2be2578&gt; 127.0.0.1 - - [2013-04-13 20:08:03] "POST /https://www.facebook.com/login.php?login_attempt=1 HTTP/1.1" 500 21 "http://127.0.0.1:8088/http://www.facebook.com" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0" </code></pre> <p>My guess with happens because of some problem while creating WSGI response but I could figure out exactly why. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload