Skip to content

Instantly share code, notes, and snippets.

@lavarini
Created October 18, 2013 16:08
Show Gist options
  • Save lavarini/7043827 to your computer and use it in GitHub Desktop.
Save lavarini/7043827 to your computer and use it in GitHub Desktop.
Urllib com proxy
# -*- coding: utf-8 -*-
import urllib2
from bs4 import BeautifulSoup
import re
import time
from StringIO import StringIO
import gzip
def make_request(url):
proxy_support = urllib2.ProxyHandler({"http":"http://187.32.127.161:3128"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
f = urllib2.urlopen(url)
# request = urllib2.Request(url)
# request.add_header('Accept-encoding', 'gzip')
# response = urllib2.urlopen(request)
# buf = StringIO( response.read())
# f = gzip.GzipFile(fileobj=buf)
data = f.read()
return BeautifulSoup(data)
def main():
temp = make_request('http://mangafox.me/manga/naruto/v66/c631/1.html')
import pdb
pdb.set_trace()
if __name__=="__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment