python 3 报错 urllib.error.URLError: <urlopen error unknown url type: "http>

尝试爬取新浪首页新闻到本地 程序报错
源码为:
import urllib.request,re
url="https://www.sina.com.cn/"
req=urllib.request.Request(url)
req.add_header("User-Agent","马赛克")
pat1='.*?'
data1=urllib.request.urlopen(req).read().decode("UTF-8","ignore")
allink=re.compile(pat1).findall(data1)
for i in range(0,len(allink)):
thislink=allink[i]
pat2=''
req2=urllib.request.Request(url)
req2.add_header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:65.0) Gecko/20100101 Firefox/65.0")
thispage=urllib.request.urlopen(req2).read().decode("UTF-8","ignore")
isframe=re.compile(pat2).findall(thispage)
if len(isframe)==0:
urllib.request.urlretrieve(thislink,"data/"+str(i)+".html")
else:
flink=isframe[0]
urllib.request.urlretrieve(flink,"data/"+str(i)+".html")
报错信息:
Traceback (most recent call last):
File "/Users/tanzhouyan/Desktop/python/新闻爬虫.py", line 73, in
urllib.request.urlretrieve(thislink,"data/"+str(i)+".html")
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 548, in _open
'unknown_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1387, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError:

在网上一直没有找到解决方法,谢谢大家~

1个回答

先装openssl:sudo yum install openssl-devel
再重装python
然后重试

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
rllib.error.HTTPError: HTTP Error 403: Forbidden

python小白,下列代码出现urllib.error.HTTPError: HTTP Error 403: Forbidden,不知怎么解决,求各位大佬帮忙。 ``` """ Retrieve radar data from the NASA and plot a view of the Grand Canyon landscape. We cannot display the whole data, as it would be too big. To display more, see the canyon decimation example. This example is interesting as it shows how numpy can be used to load and crop data completly foreign to Mayavi. """ # Author: Gael Varoquaux <gael.varoquaux@normalesup.org> # Copyright (c) 2008, Enthought, Inc. # License: BSD Style. # Retrieve the grand Canyon topological data ################################## import os # Original file: #'ftp://e0srp01u.ecs.nasa.gov/srtm/version2/SRTM1/Region_04/N39E115.hgt.zip' if not os.path.exists('N39E115.hgt.zip'): # Download the data try: from urllib import urlopen except ImportError: from urllib.request import urlopen print('Downloading data, please wait (10M)') opener = urlopen( 'https://s3.amazonaws.com/storage.enthought.com/www/sample_data/N39E115.hgt.zip' ) open('N39E115.hgt.zip', 'wb').write(opener.read()) # Load the data (signed 2 byte integers, big endian) ########################## import zipfile import numpy as np data = np.fromstring(zipfile.ZipFile('N39E115.hgt.zip').read('N39E115.hgt'), '>i2') data.shape = (3601, 3601) data = data.astype(np.float32) # Plot an interesting section ################################################# from mayavi import mlab data = data[:1000, 900:1900] # Convert missing values into something more sensible. data[data == -32768] = data[data > 0].min() mlab.figure(size=(400, 320), bgcolor=(0.16, 0.28, 0.46)) mlab.surf(data, colormap='gist_earth', warp_scale=0.2, vmin=1200, vmax=1610) # The data takes a lot of memory, and the surf command has created a # copy. We free the inital memory. del data # A view of the canyon mlab.view(-5.9, 83, 570, [5.3, 20, 238]) mlab.show() ```

python3.65 urllib.request.Request()增加header报错

# coding:utf-8 import urllib.request import urllib.parse url = 'http://192.168.**.**:9080/api/transactions' header = { 'Content-Type': 'application/json' } values ={ "currentToken": { "simplifiedName": "ETH", "address": "0x5bcd4d0508bc86c48760d0805962261d260d7a88" }, "txid": "" } data = urllib.parse.urlencode(values) data = data.encode(encoding='UTF-8') request = urllib.request.Request(url, data, header) #request = urllib.request.Request(url, data) print("111") html = urllib.request.urlopen(request) print("222") html =html.read().decode('utf-8') print(html) #返回结果 报错 D:\tool\Python36\python.exe D:/Users/Administrator/PycharmProjects/coinPlatform/test/test6.py 111 Traceback (most recent call last): File "D:/Users/Administrator/PycharmProjects/coinPlatform/test/test6.py", line 21, in <module> html = urllib.request.urlopen(request) File "D:\tool\Python36\lib\urllib\request.py", line 223, in urlopen return opener.open(url, data, timeout) File "D:\tool\Python36\lib\urllib\request.py", line 532, in open response = meth(req, response) File "D:\tool\Python36\lib\urllib\request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "D:\tool\Python36\lib\urllib\request.py", line 570, in error return self._call_chain(*args) File "D:\tool\Python36\lib\urllib\request.py", line 504, in _call_chain result = func(*args) File "D:\tool\Python36\lib\urllib\request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not Found Process finished with exit code 1 # coding:utf-8 import urllib.request import urllib.parse url = 'http://192.168.**.**:9080/api/transactions' header = { 'Content-Type': 'application/json' } values ={ "currentToken": { "simplifiedName": "ETH", "address": "0x5bcd4d0508bc86c48760d0805962261d260d7a88" }, "txid": "" } data = urllib.parse.urlencode(values) data = data.encode(encoding='UTF-8') #request = urllib.request.Request(url, data, header) request = urllib.request.Request(url, data) print("111") html = urllib.request.urlopen(request) print("222") html =html.read().decode('utf-8') print(html) 返回结果 成功 但没得到想要的结果 D:\tool\Python36\python.exe D:/Users/Administrator/PycharmProjects/coinPlatform/test/test6.py 111 222 {"code":0,"message":"success","data":{"currentToken":{},"transactions":[]}} Process finished with exit code 0

ubuntu16.04下python打开http/https报错

![ubuntu16.04下使用python中的urllib.urlopen()打开https报错IOError](https://img-ask.csdn.net/upload/201708/27/1503834919_805174.png) ``` >>> import urllib >>> urllib.urlopen('https://www.baidu.com') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/urllib.py", line 87, in urlopen return opener.open(url) File "/usr/local/lib/python2.7/urllib.py", line 210, in open return self.open_unknown(fullurl, data) File "/usr/local/lib/python2.7/urllib.py", line 222, in open_unknown raise IOError, ('url error', 'unknown url type', type) IOError: [Errno url error] unknown url type: 'https' ``` 报错信息:IOError: [Errno url error] unknown url type: 'https' ![ubuntu16.04下使用python中的urllib2.urlopen()打开https/http报错](https://img-ask.csdn.net/upload/201708/27/1503835100_415721.png) ``` >>> import urllib2 >>> urllib2.urlopen('https://www.baidu.com') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python2.7/urllib2.py", line 429, in open response = self._open(req, data) File "/usr/local/lib/python2.7/urllib2.py", line 452, in _open 'unknown_open', req) File "/usr/local/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/usr/local/lib/python2.7/urllib2.py", line 1266, in unknown_open raise URLError('unknown url type: %s' % type) urllib2.URLError: <urlopen error unknown url type: https> >>> urllib2.urlopen('http://www.baidu.com') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/local/lib/python2.7/urllib2.py", line 429, in open response = self._open(req, data) File "/usr/local/lib/python2.7/urllib2.py", line 447, in _open '_open', req) File "/usr/local/lib/python2.7/urllib2.py", line 407, in _call_chain result = func(*args) File "/usr/local/lib/python2.7/urllib2.py", line 1228, in http_open return self.do_open(httplib.HTTPConnection, req) File "/usr/local/lib/python2.7/urllib2.py", line 1198, in do_open raise URLError(err) urllib2.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> >>> ``` 报错信息: urllib2.URLError: <urlopen error unknown url type: https> urllib2.URLError: <urlopen error [Errno -3] Temporary failure in name resolution> 这个要如何解决?求大神指点迷津,谢谢!

URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接?

当我输入下面这段代码:iris = sns.load_dataset('iris') sns.pairplot(iris) 就会出现下面这样的报错,找了几个小时也找不出来原因,请大神解决! C:\ProgramData\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 502 for handler in handlers: 503 func = getattr(handler, meth_name) --> 504 result = func(*args) 505 if result is not None: 506 return result C:\ProgramData\Anaconda3\lib\urllib\request.py in https_open(self, req) 1359 def https_open(self, req): 1360 return self.do_open(http.client.HTTPSConnection, req, -> 1361 context=self._context, check_hostname=self._check_hostname) 1362 1363 https_request = AbstractHTTPHandler.do_request_ C:\ProgramData\Anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 1318 encode_chunked=req.has_header('Transfer-encoding')) 1319 except OSError as err: # timeout error -> 1320 raise URLError(err) 1321 r = h.getresponse() 1322 except: 1. * 1. URLError: <urlopen error [WinError 10054] 远程主机强迫关闭了一个现有的连接。>

urllib2.URLError: <urlopen error [Errno 104] Connection reset by peer>

python爬虫使用mechanize模拟登陆出现,求解决方法,没有在代码中添加代理ip,不知到如何解决,已经困扰我一上午了,不知道哪位大侠可以帮忙啊!

python3爬虫遇到报错 “urlopen error no host given”

程序是爬百度图片搜索范冰冰的所有图片。Notepad已经选择了UTF8编码,URL地址也没有回车分行。 直接上代码如下: import urllib.request import re import sys import os import urllib import ssl #根据给定的网址来获取网页详细信息,得到的html就是网页的源代码 def getHtml(url): page = urllib.request.urlopen(url) html = page.read() return html.decode('utf-8') def getImg(html): imglist = re.findall('"ObjURL":"(.*?)",', html, re.S)#表示在整个网页中过滤出所有图片的地址,放在imglist中 x = 0 path = 'D:\\test' # 将图片保存到D:\\test文件夹中,如果没有test文件夹则创建 if not os.path.isdir(path): os.makedirs(path) paths = path+'\\' #保存在test路径下 for imgurl in imglist: urllib.request.urlretrieve(imgurl,'D:\\test\\%s.jpg' % x) #打开imglist中保存的图片网址,并下载图片保存在本地,format格式化字符串 x = x + 1 return imglist url="http://image.baidu.com/search/index?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=%E8%8C%83%E5%86%B0%E5%86%B0" html=getHtml(url) print (getImg(html)) #从网页源代码中分析并下载保存图片

python无法访问https出现URLError

URLError: "urlopen error [Errno 8] _ssl.c:503: EOF occurred in violation of protocol" 直接通过浏览器可以访问,昨天也是好使的,今天就不行了 代码: url="https://ipaddress/xxx/xxx/xxx" kw={'xxx':'xxx'} data = urllib.urlencode(kw) req = urllib2.Request(url,data) base64string = base64.encodestring('%s:%s' % ('xxx', 'xxx'))[:-1] #这里最后会自动添加一个\n authheader = "Basic %s" % base64string req.add_header("Authorization", authheader) return_data = urllib2.urlopen(req) #请求url data = return_data.read() #读取内容 print data 错误: Traceback (most recent call last): File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 323, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python27\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python27\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 655, in run exec cmd in globals, locals File "C:\Users\wzs\Desktop\get_resulte.py", line 2, in <module> import urllib File "C:\Python27\lib\urllib2.py", line 126, in urlopen return _opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 394, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 412, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 372, in _call_chain result = func(*args) File "C:\Python27\lib\urllib2.py", line 1207, in https_open return self.do_open(httplib.HTTPSConnection, req) File "C:\Python27\lib\urllib2.py", line 1174, in do_open raise URLError(err) URLError:<urlopen error [Errno 8] _ssl.c:503: EOF occurred in violation of protocol>

python报错:requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')"))

代码如下: ``` #!/usr/bin/env python # coding=utf-8 #import importlib,sys #import sys #sys.setdefaultencoding('gbk') from urllib.parse import quote '''import sys import imp import sys reload(sys) sys.setdefaultencoding('utf8') ''' ''' import urllib import urllib2 import requests import sys sys.setdefaultencoding('utf-8') import jieba import json''' #from bs4 import BeautifulSoup import urllib.request import urllib.parse as parse import ssl import re import os,os.path import codecs import requests def getText(html): '''headers = {'Host': 'https://pypi.org','User-Agent':'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER','Referer': 'https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch, br', 'Accept-Language': 'zh-CN,zh;q=0.8'} #req = urllib.urlretrieve(download_url,headers=headers) ''' #urllib.request.urlopen('https://www.lfd.uci.edu/~gohlke/pythonlibs/') #req = urllib.request.Request(url=url,headers=header) #headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'} #import requests res = requests.get(html) res.encoding = 'utf-8' #print(res.text) words=res.text ''' soup = BeautifulSoup(res.text, "html.parser") words = "" for a1 in soup.find_all("a"): words = words + str(a1.string) ''' return words def file(url1,file_name,name): print(url1) headers = {'Host': 'https://files.pythonhosted.org/packages/','User-Agent':'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER','Referer': 'https://pypi.org/', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch, br', 'Accept-Language': 'zh-CN,zh;q=0.8'} #req = urllib.urlretrieve(download_url,headers=headers) #urllib.request.urlopen('https://www.lfd.uci.edu/~gohlke/pythonlibs/') #req = urllib.request.Request(url=url,headers=header) request = requests.get(url=url1,headers=headers) #response = urllib.request.urlopen(request) global i i += 1 print(request.content) file = open(name ,'wb+') file.write(request.content) file.close() print(file_name) print("Completed : .... %d ..." % x) '''for i in range(len(name_list)): j=0 if name_list[i-24:i+1]=='https://pypi.org/project/': name_list1.append(name_list[i+1:i+60])''' def get(url): global name_list1 res=getText(url) #print('\n\n\n\n\n\nok\n\n\n\n\n\n\n\n\n\n') #name_list = getText(url) #print(res) print('html done,page:'+str(count)+'\n') for i in range(len(res)): #j=0 if (res[i-8:i+1]=='/project/')==True: name_list1.append('https://pypi.org'+res[i-8:i+20]) #print(name_list1) def trim(list1): k=0 list2=[] for i in list1: j=25 while j<len(list1[k]): if list1[k][j]=='/': list2.append(list1[k][0:j]) break j+=1 k+=1 return list2 def get1(url): """o=0 for n in len(url): if url[n]=='"': url=url[0:n-1]+'#files' """ global namelist url=url+'#files' #import requests res = requests.get(url) res.encoding = 'utf-8' #print(res.text) html=res.text for p in range(len(html)): stri='https://files' if html[p-len(stri):p]==stri: namelist.append(html[p-len(stri):p+170]) import httplib2 as httplib httplib.HTTPConnection._http_vsn = 10 httplib.HTTPConnection._http_vsn_str = 'HTTP/1.0' ''' #-*- coding:utf-8 -*- import time import hmac import hashlib import requests import json import mysql.connector import requests import httplib2 as httplib import urllib from urllib import unquote import json def query_total_flow(): header = {"Content-Type": "application/json", 'Connection': 'close', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'} post_data = { "operator": "xxxxxx", # 调用系统的名字 "type": "set", "set_id": [1], "set_name": [], "feature_type": ["入流量"], "date": "2019-06-15", "begintime": "23:55", "endtime": "23:59", } url = "http://xxx.xxx.xxx.xxx:80/xxxxx/xxxxx/xxxxx.cgi/json?" post_data = json.dumps(post_data, ensure_ascii=False, separators=(',',':')) print (post_data) # url = url + post_data url = url + urllib.urlencode({'data': post_data}) # data = urllib.urlencode({'data': post_data}) # print post_data # print data data = unquote(url) try: # print data print (data) response = requests.get(url, json=data, timeout=60, headers=header) print (response.headers) print (response.url) print (response.text.encode('utf-8')) if response['code'] != 0: result_dict = json.loads(response.text) data = result_dict["data"] print(data) print(data) set_info = [] return response raise exp_with_err_instance(err.RESULT_ERROR, 'can not find inst info') print ("none!") return [] except Exception as e: print ("Exception") raise if __name__ == "__main__": query_total_flow() ''' save_path = os.getcwd() ''' url = 'https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3' name_list = getText(url) print(name_list) print('html done') #html.decode('utf-8') #print(name_list)''' x=1 files=os.listdir(save_path) #print(files) #print(type(name_list)) name_list1=[] #print(name_list) #for name in name_list: k=0 # name[k]=str(name1[k]) '''for i in range(len(name_list)): j=0 if name_list[i-25:i+1]=='https://pypi.org/project/': name_list1.append(name_list[i-25:i+20]) for u in range(len(name_list1[len(name_list1)])): if name_list1[len(name_list1)][u]==' ': name_list1[len(name_list1)]=name_list1[len(name_list1)][0:u-1] ''' global count count=2 name_list1=[] for count in range(51): get('https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3&page='+str(count)) """ global m if k<len(name_list1): for l in range(len(name_list1[k])): if l-9>=0: if name_list1[k][l-4:l]=='.whl' or name_list1[k][l-3:l]=='.gz' or name_list1[k][l-4:l]=='.zip': j=1 m=l if j==1: name_list1[k]=name_list1[k][0:m] k+=1""" '''if j==0: name_list.remove(name)''' #file_name = os.path.join(save_path ,name) #i=0 #print(name) #print(name_list1) namelist=[] h=0 for y in trim(name_list1): get1(y) #print(namelist) '''if h==3: break''' h+=1 i=0 for name in namelist: j=0 for l in range(len(name)): if l-9>=0: if name[l-4:l]=='.whl' or name[l-3:l]=='.gz' or name[l-4:l]=='.zip': j=1 m=l break if j==1: name=name[0:m] k+=1 while m>0: if m<len(name): if name[m]=='/': filename=name[m+1:len(name)]#p] break m-=1 if filename in files: continue '''if name=='Delny‑0.4.1‑cp27‑none‑win_amd64.whl</a></li>\n<li>' or name==Delny‑0.4.1‑cp27‑none‑win32.whl</a></li> </ul> </: continue ''' print('no:'+str(x)) print('\ndownload '+name) # importlib.reload(sys) #imp.reload(sys) for l in range(len(name)): if l-9>=0: if name[l-4:l]=='.whl' or name[l-3:l]=='.gz' or name[l-4:l]=='.zip': j=1 m=l break if j==1: name=name[0:m] k+=1 p=m #string='https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/' + name#[0:4+name.find('.whl')]#https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/ print('00'+save_path) #file(name,save_path,filename) url1=name +'/' + filename url1=url1.encode() name=filename file_name=save_path #file = open(name ,'wb+') #file.write(url1 ) #file.close() #print(file_name) headers = {'Host': 'https://files.pythonhosted.org/packages/','User-Agent':'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER','Referer': 'https://pypi.org/', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 LBBROWSER', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch, br', 'Accept-Language': 'zh-CN,zh;q=0.8'} #req = urllib.urlretrieve(download_url,headers=headers) #urllib.request.urlopen('https://www.lfd.uci.edu/~gohlke/pythonlibs/') #req = urllib.request.Request(url=url,headers=header) #request = urllib.request.urlopen(url1) #response = urllib.request.urlopen(request) urllib.request.urlretrieve(url1.decode(),name) i += 1 print(url1.decode()) #file = open(name ,'wt+') #file.write(str(req.content())) #file.close() print(file_name) print("Completed : .... %d ..." % x) '''for i in range(len(name_list)): j=0 if name_list[i-24:i+1]=='https://pypi.org/project/': name_list1.append(name_list[i+1:i+60])''' print('\n........'+filename+'..........complete\n') x=x+1 print('09') print('finished') ``` 报错: Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> ===================== RESTART: E:\2345Downloads\版本2下载whl.py ==================== Traceback (most recent call last): File "E:\2345Downloads\版本2下载whl.py", line 154, in <module> httplib.HTTPConnection._http_vsn = 10 AttributeError: module 'httplib2' has no attribute 'HTTPConnection' >>> 如果不加 ``` import httplib2 as httplib httplib.HTTPConnection._http_vsn = 10 httplib.HTTPConnection._http_vsn_str = 'HTTP/1.0' ``` 就会 Traceback (most recent call last): File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "<string>", line 3, in raise_from File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse response.begin() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin version, status, reason = self._read_status() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 264, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\contrib\pyopenssl.py", line 318, in recv_into raise SocketError(str(e)) OSError: (10060, 'WSAETIMEDOUT') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen( File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen retries = retries.increment( File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 400, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\packages\six.py", line 734, in reraise raise value.with_traceback(tb) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen httplib_response = self._make_request( File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request six.raise_from(e, None) File "<string>", line 3, in raise_from File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request httplib_response = conn.getresponse() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse response.begin() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin version, status, reason = self._read_status() File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 264, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\contrib\pyopenssl.py", line 318, in recv_into raise SocketError(str(e)) urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')")) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\2345Downloads\版本2下载whl.py", line 282, in <module> get1(y) File "E:\2345Downloads\版本2下载whl.py", line 141, in get1 res = requests.get(url) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, **kwargs) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')")) 求高手解决

urllib2.HTTPError 407 Proxy Authentication

python 2.7 w7 proxy = 'http://%s:%s@%s:%s' % (user, passwd, proxyserver,port) proxy_support = urllib2.ProxyHandler({'http':proxy}) opener = urllib2.build_opener(proxy_support ) urllib2.install_opener( opener ) sContent = urllib2.urlopen(url)

python3用urllib.request为什么会导致程序不停的爬取数据而导致程序崩溃?

这是我的源代码![图片说明](https://img-ask.csdn.net/upload/201707/05/1499221937_157417.png) 然后这是运行之后![图片说明](https://img-ask.csdn.net/upload/201707/05/1499221968_890861.png) 就一直卡住,一直在爬数据,请问为什么呢?

Python使用urllib2 urlopen打开网页不正确

``` #!/usr/bin/python # -*- coding: utf-8 -*- import urllib; import urllib2; import os; import sys; import shutil; def searchVT(): VTMainUrl = 'https://www.virustotal.com/en/#search'; headers = { 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'content-type':'application/x-www-form-urlencode', 'referer':'https://www.virustotal.com/', 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36'}; postDict = {'query' : '18092AC0F4F694C60762DC98C9F66BC3',}; postData = urllib.urlencode(postDict); req = urllib2.Request(VTMainUrl, postData, headers); try: respHtml = urllib2.urlopen(req).read(); except urllib2.URLError,e: if hasattr(e,"reason"): print "Failed to reach the server" print "The reason:",e.reason elif hasattr(e,"code"): print "The server couldn't fulfill the request" print "Error code:",e.code print "Return content:",e.read() else: pass #其他异常的处理 file_object = open('thefile.txt', 'w') file_object.write(respHtml) file_object.close( ) print respHtml; return respHtml; if __name__=="__main__": searchVT(); ``` 最近使用urllib2 urlopen尝试打开VT网页并进行使用MD5查询,但是不知道为什么返回的网页为空,求大神赐教~

Help!python pycharm 导入urllib.request 时的问题

当我在pycharm中 使用 from urllib.request import urlopen 时 程序运行会报错 提示我 client.py 没有 email.parser 这个module,但是我在python自带的idle中,这样导入就没有问题~麻烦大神帮我看下。。因为pycharm的确太好用了。。如何帮我解决这个问题~

python获取微博接口发微博出现403禁止访问的情况

利用微博的开放的接口,加上大佬的weibo sdk包,最后使用post.statuses update方法 来提交post请求,从而发一条微博。使用它的get方法的时候都没有问题的,但是一使用它的post中的请求的时候就会出问题: ``` urllib.error.HTTPError: HTTP Error 403: Forbidden ``` 下面是我整个的代码: ``` from weibo import APIClient import urllib.request import urllib.parse def weibo(): APP_KEY = '528248027' APP_SECRET = '4dfcbaf24dc2341d41aea5b462ac61f6' CALLBACK_URL = 'https://api.weibo.com/oauth2/default.html' OAUTH_URL = 'https://api.weibo.com/oauth2/default.html' USER_ID = '6270069375' PASSWORD = '19981027lcy' client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL) refer_url = client.get_authorize_url() print("refer_url is :", refer_url) cookies = urllib.request.HTTPCookieProcessor() opener = urllib.request.build_opener(cookies) urllib.request.install_opener(opener) postdata = { 'client_id': APP_KEY, 'redirect_uri': CALLBACK_URL, 'userId': USER_ID, 'passwd': PASSWORD, 'isLoginSina': "1", 'action': 'submit', 'response_type': 'code' } headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36', 'Host': 'open.weibo.com', 'Referer': refer_url } req = urllib.request.Request( url=OAUTH_URL, data=urllib.parse.urlencode(postdata).encode(encoding='UTF8'), headers=headers, ) resp = urllib.request.urlopen(req) print('callback url is :', resp.geturl()) pat = 'code=(.*?)$' print(resp.geturl()) code = input('input code:') print('code is :', code) r = client.request_access_token(code, redirect_uri=CALLBACK_URL) access_token1 = r.access_token expires_in = r.expires_in print('access_token=', access_token1) print('expires_in=', expires_in) #client.set_access_token(access_token1, expires_in) return client, access_token1, refer_url, expires_in def main(): client, access_token, refer_url, expires_in = weibo() client.set_access_token(access_token=access_token, expires_in=expires_in)#已经设置的授权,所有的get方法都是行得通的,就是不能提交post请求 print('用户id:', client.get.account__get_uid()) result5 = client.post.statuses__update(source='528248027', status='写一个小微博', geo_enabled=True)#发一条微博 print(result5) if __name__ == '__main__': main() ``` 这个要是放在爬虫里面,就是需要加一些headers就可以解决了,但是在这里面,我已经获得授权了,就是已经设置过了client的access_token: ``` client.set_access_token(access_token=access_token, expires_in=expires_in) ```

ubuntu上python无法爬取网页

在ubuntu12.04下写了个简单的python测试代码: # -*- coding: UTF-8 -*- import time,urllib2,urllib,StringIO,sys,os,multiprocessing,sqlite3 if __name__ == '__main__': stockUrl="http://www.baidu.com" stockWeb = urllib.urlopen(stockUrl).read() print stockWeb 但是出现了如下错误: Traceback (most recent call last): File "test.py", line 6, in <module> stockWeb = urllib.urlopen(stockUrl).read() File "/usr/lib/python2.7/urllib.py", line 86, in urlopen return opener.open(url) File "/usr/lib/python2.7/urllib.py", line 207, in open return getattr(self, name)(url) File "/usr/lib/python2.7/urllib.py", line 344, in open_http h.endheaders(data) File "/usr/lib/python2.7/httplib.py", line 954, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 814, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 776, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 757, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): IOError: [Errno socket error] [Errno -2] Name or service not known GOOGLE了也没找到解决办法,这是什么问题? 另外,同样的代码吗,我在另一台同样环境机器上是可以运行的

urlopen以一种访问权限不允许的方式做了一个访问套接字的尝试。

import urllib.request url="http://www.baidu.com" req=urllib.request.urlopen(url) 然后报错 Traceback (most recent call last): File "D:\python344\lib\urllib\request.py", line 1183, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "D:\python344\lib\http\client.py", line 1137, in request self._send_request(method, url, body, headers) File "D:\python344\lib\http\client.py", line 1182, in _send_request self.endheaders(body) File "D:\python344\lib\http\client.py", line 1133, in endheaders self._send_output(message_body) File "D:\python344\lib\http\client.py", line 963, in _send_output self.send(msg) File "D:\python344\lib\http\client.py", line 898, in send self.connect() File "D:\python344\lib\http\client.py", line 871, in connect self.timeout, self.source_address) File "D:\python344\lib\socket.py", line 516, in create_connection raise err File "D:\python344\lib\socket.py", line 507, in create_connection sock.connect(sa) OSError: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> req=urllib.request.urlopen(url) File "D:\python344\lib\urllib\request.py", line 161, in urlopen return opener.open(url, data, timeout) File "D:\python344\lib\urllib\request.py", line 464, in open response = self._open(req, data) File "D:\python344\lib\urllib\request.py", line 482, in _open '_open', req) File "D:\python344\lib\urllib\request.py", line 442, in _call_chain result = func(*args) File "D:\python344\lib\urllib\request.py", line 1211, in http_open return self.do_open(http.client.HTTPConnection, req) File "D:\python344\lib\urllib\request.py", line 1185, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。>

python爬虫的奇葩错误,socket.gaierror: [Errno 11001] getaddrinfo failed

```''' 文件名:爬取斗鱼直播间信息到jsonline文件.py ''' from __future__ import unicode_literals import multiprocessing import socket import time import re import requests from bs4 import BeautifulSoup import json # 配置socket的ip和端口 client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostbyname("openbarrage.douyutv.com") port = 8601 client.connect((host, port)) # 获取用户昵称及弹幕信息的正则表达式 danmu = re.compile(b'type@=chatmsg.*?/nn@=(.*?)/txt@=(.*?)/.*?/level@=(.*?)/.*?/bnn@=(.*?)/bl@=(.*?)/') def sendmsg(msgstr): ''' 客户端向服务器发送请求的函数,集成发送协议头的功能 msgHead: 发送数据前的协议头,消息长度的两倍,及消息类型、加密字段和保密字段 使用while循环发送具体数据,保证将数据都发送出去 ''' msg = msgstr.encode('utf-8') data_length = len(msg) + 8 code = 689 msgHead = int.to_bytes(data_length, 4, 'little') \ + int.to_bytes(data_length, 4, 'little') + int.to_bytes(code, 4, 'little') client.send(msgHead) sent = 0 while sent < len(msg): tn = client.send(msg[sent:]) sent = sent + tn def start(roomid): ''' 发送登录验证请求后,获取服务器返回的弹幕信息,同时提取昵称及弹幕内容 登陆请求消息及入组消息末尾要加入\0 ''' msg = 'type@=loginreq/roomid@={}/\0'.format(roomid) sendmsg(msg) msg_more = 'type@=joingroup/rid@={}/gid@=-9999/\0'.format(roomid) sendmsg(msg_more) print('---------------欢迎连接到{}的直播间---------------'.format(get_name(roomid))) while True: data = client.recv(1024) danmu_more = danmu.findall(data) if not data: break else: with open(format(get_name(roomid)) + time.strftime('%Y.%m.%d', time.localtime(time.time())) + '直播弹幕', 'a') as f: try: for i in danmu_more: dmDict = {} # print(i) dmDict['昵称'] = i[0].decode(encoding='utf-8', errors='ignore') dmDict['弹幕内容'] = i[1].decode(encoding='utf-8', errors='ignore') dmDict['等级'] = i[2].decode(encoding='utf-8', errors='ignore') dmDict['徽章昵称'] = i[3].decode(encoding='utf-8', errors='ignore') dmDict['徽章等级'] = i[4].decode(encoding='utf-8', errors='ignore') dmJsonStr = json.dumps(dmDict, ensure_ascii=False) + '\n' # print(dmDict['昵称']) print(dmDict['弹幕内容']) f.write(dmJsonStr) danmuNum = danmuNum + 1 except: continue def keeplive(): ''' 发送心跳信息,维持TCP长连接 心跳消息末尾加入\0 ''' while True: msg = 'type@=mrkl/\0' sendmsg(msg) time.sleep(45) def get_name(roomid): ''' 利用BeautifulSoup获取直播间标题 ''' r = requests.get("http://www.douyu.com/" + roomid) soup = BeautifulSoup(r.text, 'lxml') return soup.find('a', {'class', 'Title-anchorName'}).string # 启动程序 if __name__ == '__main__': room_id = input('请输入房间ID: ') p1 = multiprocessing.Process(target=start, args=(room_id,)) p2 = multiprocessing.Process(target=keeplive) p1.start() p2.start() ```在别人电脑可以运行,但是在自己的电脑上就报错 附上报错截图,有大神可以帮忙处理一下吗?万分感谢 报错: E:\pythonzzz\venv\Scripts\python.exe E:/pythonzzz/爬虫/z3.py Traceback (most recent call last): File "E:/pythonzzz/爬虫/z3.py", line 17, in <module> host = socket.gethostbyname("openbarrage.douyutv.com") socket.gaierror: [Errno 11001] getaddrinfo failed Process finished with exit code 1

Python3.4用cx_Freeze打包的时候出问题了,不知道怎么解决啊

![CSDN移动问答][1] [1]: http://imgsrc.baidu.com/forum/pic/item/3f73612762d0f703bb75eadb0bfa513d2797c556.jpg 上面是EXE运行时的状况; 下面试代码: #! /usr/bin/python # -*- coding: utf-8 -*- import urllib.request,urllib.error try: resp=urllib.request.urlopen('http://su.bdimg.com/static/superplus/img/logo_white_ee663702.png') html=resp.read() spath="e:/1.png" f=open(spath,"wb") # Opens file for writing.Creates this file doesn't exist. f.write(html) f.close() #print(html) except urllib.error.HTTPError as err: print(err.code ) except urllib.error.URLError as err: print(err.code ) 当我使用cx_freeze打包一些简单的输入输出时完全可以运行

关于python3.x 编写爬虫的报错问题

找了好几天的资料还是没能解决,拜托各位! ``` import urllib.error import urllib.request import urllib.parse url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=https://www.baidu.com/link HTTP/1.1' data = {} data['type']= 'AUTO' data['i'] = 'I am fine !' data['doctype'] = 'json' data['xmlVersion'] = '1.8' data['keyfrom'] = 'fanyi.web' data['ue'] = 'UTF-8' data['action'] = 'FY_BY_CLICKBUTTON' data['typoResult'] = 'true' head = {} head['User-Agent']= 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0' try: data = urllib.parse.urlencode(data).encode('utf-8') req = urllib.request.Request(url,data,head) response = urllib.request.urlopen(req) html = response.read().decode('utf-8') print(html) except urllib.error.HTTPError as e: print ('Error code : ',e.code) except urllib.error.URLError as e: print ('The reason: ',e.reason) ``` 抛出异常: ![图片说明](https://img-ask.csdn.net/upload/201703/09/1489022080_873412.png)

requests已经安装好,但是执行 r = requests.get("http://www.baidu.com")后出现以下提示

requests已经安装好,但是执行 r = requests.get("http://www.baidu.com")后出现以下提示,要怎么设置才能正常获取网页信息 >>> r = requests.get("http://www.baidu.com") Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 597, in urlopen self._prepare_proxy(conn) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 807, in _prepare_proxy conn.connect() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connection.py", line 370, in connect ssl_context=context) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\ssl_.py", line 355, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 407, in wrap_socket _context=self, _session=session) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 814, in __init__ self.do_handshake() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 1068, in do_handshake self._sslobj.do_handshake() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\ssl.py", line 689, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\urllib3\util\retry.py", line 399, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: /?tn=56080572_10_hao_pg (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> r = requests.get("http://www.baidu.com") File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 668, in send history = [resp for resp in gen] if allow_redirects else [] File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 668, in <listcomp> history = [resp for resp in gen] if allow_redirects else [] File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 247, in resolve_redirects **adapter_kwargs File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: /?tn=56080572_10_hao_pg (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) 但是执行>>> r = requests.get("http://www.126.com")是正常的 >>> print(r.status_code) 200 >>> r.text

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

win10暴力查看wifi密码

刚才邻居打了个电话说:喂小灰,你家wifi的密码是多少,我怎么连不上了。 我。。。 我也忘了哎,就找到了一个好办法,分享给大家: 第一种情况:已经连接上的wifi,怎么知道密码? 打开:控制面板\网络和 Internet\网络连接 然后右击wifi连接的无线网卡,选择状态 然后像下图一样: 第二种情况:前提是我不知道啊,但是我以前知道密码。 此时可以利用dos命令了 1、利用netsh wlan...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

!大部分程序员只会写3年代码

如果世界上都是这种不思进取的软件公司,那别说大部分程序员只会写 3 年代码,恐怕就没有程序员这种职业。

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

美团面试,问了ThreadLocal原理,这个回答让我通过了

他想都想不到,ThreadLocal我烂熟于心

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

立即提问
相关内容推荐