Skip to content

Instantly share code, notes, and snippets.

Created July 19, 2017 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5675cf38b29cb522452024ae92c33097 to your computer and use it in GitHub Desktop.
Save anonymous/5675cf38b29cb522452024ae92c33097 to your computer and use it in GitHub Desktop.
r = requests.get('http://127.0.0.1:8000/?types=0&count=5&country=国内')
ip_ports = json.loads(r.text)
print(ip_ports)
i = random.randint(0,4)
print(i)
ip = ip_ports[i][0]
port = ip_ports[i][1]
proxies={
'http':'http://%s:%s'%(ip,port),
'https':'http://%s:%s'%(ip,port)
}
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel… Gecko/20100101 Firefox/54.0'}
r = requests.get('http://ip.chinaz.com/', headers=headers, proxies=proxies)
r.encoding='utf-8'
print(r.status_code)
print(proxies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment