Skip to content

Instantly share code, notes, and snippets.

@swshan
Created April 27, 2016 09:36
Show Gist options
  • Save swshan/849adbfc492809b7f8e67d6ce4eccaac to your computer and use it in GitHub Desktop.
Save swshan/849adbfc492809b7f8e67d6ce4eccaac to your computer and use it in GitHub Desktop.
import requests
import random
def getproxy():
foo = ['124.200.33.146:8118', '112.90.72.83:80']
rand = random.choice((foo))
''' Get a dict format proxy randomly '''
proxy= rand
proxies={'http':'http://'+proxy}
r = requests.get('http://www.douban.com',proxies=proxies,timeout=1)
print r.text
if __name__ == '__main__':
getproxy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment