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

来源:互联网 发布:伊美服饰淘宝网 编辑:程序博客网 时间:2024/05/29 09:30
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
原创粉丝点击