<reponame>ericwhyne/http-ricochet<filename>example-query.py<gh_stars>10-100
#!/usr/bin/python
import urllib2
import random

# A list of places we've deployed ricochet
ricochet_servers = [
"http://127.0.0.1:8080/ricochet/ricochet?url=",
"http://127.0.0.1:8080/ricochet/ricochet?url="
]

# We're identifying ourselves to ourself here, this will show up in the server logs (unless you've disabled them).
headers = { 'User-Agent' : 'Its me!' }

# Pick a random server, build the query, then make the query.
ricochet_server = random.choice(ricochet_servers)
content_type = "&ct=text/html"
url = "http://news.ycombinator.com"
# use urllib2.quote if your url contains parameters, the ricochet proxy will unquote before making the request
# url = urllib2.quote("https://news.ycombinator.com/newest?n=31")
query = ricochet_server + url + content_type

print urllib2.urlopen(urllib2.Request(query, None, headers)).read()

#!/usr/bin/python
import urllib2
import random

# A list of places we've deployed ricochet
ricochet_servers = [
"http://127.0.0.1:8080/ricochet/ricochet?url=",
"http://127.0.0.1:8080/ricochet/ricochet?url="
]

# We're identifying ourselves to ourself here, this will show up in the server logs (unless you've disabled them).
headers = { 'User-Agent' : 'Its me!' }

# Pick a random server, build the query, then make the query.
ricochet_server = random.choice(ricochet_servers)
content_type = "&ct=text/html"
url = "http://news.ycombinator.com"
# use urllib2.quote if your url contains parameters, the ricochet proxy will unquote before making the request
# url = urllib2.quote("https://news.ycombinator.com/newest?n=31")
query = ricochet_server + url + content_type

print urllib2.urlopen(urllib2.Request(query, None, headers)).read()
#!/usr/bin/python # A list of places we've deployed ricochet # We're identifying ourselves to ourself here, this will show up in the server logs (unless you've disabled them). # Pick a random server, build the query, then make the query. # use urllib2.quote if your url contains parameters, the ricochet proxy will unquote before making the request # url = urllib2.quote("https://news.ycombinator.com/newest?n=31")