您的位置:首页 > 理论基础 > 计算机网络

request请求https时禁用安全请求警告

2017-07-27 19:14 225 查看
def getPhoneLocatin():
match=re.compile(ur".*?province:'(.*?)'.*")
temp=[]
for phone in loadData():
realphone=phone
if len(str(phone).strip())>11:
phone=str(phone).strip()[:11]
try:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

#verify=False禁用证书
response=requests.get(url='http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=%s'%phone,verify=False)
search=match.search(response.content.decode('gbk'))
location=''
if search:
location=search.group(1)
temp.append((realphone,location))
if len(temp)>=5000:
cursor.executemany(sql,temp)
print '..'
conn.commit()
temp=[]
except Exception as e:
pass
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息