From 87991aff932426c44f170cdfee4d33d74ecc0a1b Mon Sep 17 00:00:00 2001 From: ddv12138 <644077730@qq.com> Date: Sun, 27 Aug 2017 12:48:54 +0800 Subject: [PATCH] =?UTF-8?q?2017=E5=B9=B408=E6=9C=8827=E6=97=A5=2012:48:54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cet_query.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cet_query.py b/cet_query.py index 378948f..a871177 100644 --- a/cet_query.py +++ b/cet_query.py @@ -16,6 +16,9 @@ from time import sleep from urllib.parse import quote from bs4 import BeautifulSoup as bs +proxy = { + 'http':'http://101.200.44.5:8888' +} URL='http://www.chsi.com.cn/cet/' data = 'query?zkzh={}&xm={}' @@ -32,11 +35,11 @@ H = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, def query(id__,name): s = requests.Session() - req = s.get(URL,headers=H) + req = s.get(URL,headers=H,proxies=proxy) if req.ok : url = URL + data.format(id__,quote(name)) - req = requests.get(url,headers=H,cookies=req.cookies) + req = requests.get(url,headers=H,cookies=req.cookies,proxies=proxy) return req.text else: print(id__,name,'出错',sep='-->')