test.py 395 B

12345678910111213141516
  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][0]
  8. port = ip_ports[0][1]
  9. proxies = {
  10. 'http': 'http://%s:%s' % (ip, port),
  11. 'https': 'http://%s:%s' % (ip, port)
  12. }
  13. r = requests.get('http://www.baidu.com', proxies=proxies)
  14. r.encoding = 'utf-8'
  15. print(r.text)