test.py 387 B

123456789101112131415
  1. #coding:utf-8
  2. import requests
  3. import json
  4. r = requests.get('http://127.0.0.1:8000/?types=0&count=5&country=中国')
  5. ip_ports = json.loads(r.text)
  6. print ip_ports
  7. ip = ip_ports[0]['ip']
  8. port = ip_ports[0]['port']
  9. proxies={
  10. 'http':'http://%s:%s'%(ip,port),
  11. 'https':'http://%s:%s'%(ip,port)
  12. }
  13. r = requests.get('http://ip.chinaz.com/',proxies=proxies)
  14. r.encoding='utf-8'
  15. print r.text