urllib

I get CERTIFICATE_VERIFY_FAILED when I try to install the spaCy English language model

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm running OS X El Capitan on Python 3.5.2 via Anaconda and have spaCy 0.101.0. I'm trying to install the spaCy English language model using python -m spacy.en.download . However when I do that, I get an error that says urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)> . The complete Traceback is as follows: Traceback ( most recent call last ): File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py" , line 1254 , in do_open h . request ( req . get_method (), req

urllib.py doesn&#039;t work with https?

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my python app I try to open a https url, but I get: File "C:\Python26\lib\urllib.py", line 215, in open_unknown raise IOError, ('url error', 'unknown url type', type) IOError: [Errno url error] unknown url type: 'https' my code: import urllib def generate_embedded_doc(doc_id): url = "https://docs.google.com/document/ub?id=" + doc_id + "&embedded=true" src = urllib.urlopen(url).read() ... return src 回答1: urllib and Python 2.6 have SSL support and your code example works fine for me. Probably your Python is built without SSL support? Try to

Python; urllib error: AttributeError: 'bytes' object has no attribute 'read'

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Note: This is Python 3, there is no urllib2. Also, I've tried using json.loads(), and I get this error: TypeError : can 't use a string pattern on a bytes-like object I get this error if I use json.loads() and remove the .read() from response: TypeError : expected string or buffer > import urllib . request import json response = urllib . request . urlopen ( 'http://www.reddit.com/r/all/top/.json' ). read () jsonResponse = json . load ( response ) for child in jsonResponse [ 'data' ][ 'children' ]: print ( child [ 'data' ][ 'title'

How to fix getaddrinfo-failure for python on windows

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: if a start python in a command prompt terminal and try to open some url, I get the following result, despite the name being resolveable through DNS: C : \Windows\system32 > nslookup www . google . de Nicht - autorisierende Antwort : Name : www - cctld . l . google . com Address : 173.194 . 69.94 Aliases : www . google . de C : \Windows\system32 > C : \Python27\python . exe Python 2.7 . 2 ( default , Jun 12 2011 , 15 : 08 : 59 ) [ MSC v . 1500 32 bit ( Intel )] on win32 Type "help" , "copyright" , "credits" or "license" for more

Python 3.4 urllib.request error (http 403)

混江龙づ霸主 提交于 2019-12-03 01:33:16
I'm trying to open and parse a html page. In python 2.7.8 I have no problem: import urllib url = "https://ipdb.at/ip/66.196.116.112" html = urllib.urlopen(url).read() and everything is fine. However I want to move to python 3.4 and there I get HTTP error 403 (Forbidden). My code: import urllib.request html = urllib.request.urlopen(url) # same URL as before File "C:\Python34\lib\urllib\request.py", line 153, in urlopen return opener.open(url, data, timeout) File "C:\Python34\lib\urllib\request.py", line 461, in open response = meth(req, response) File "C:\Python34\lib\urllib\request.py", line

What command to use instead of urllib.request.urlretrieve?

a 夏天 提交于 2019-12-03 01:27:53
I'm currently writing a script that downloads a file from a URL import urllib.request urllib.request.urlretrieve(my_url, 'my_filename') According to the docs, urllib.request.urlretrieve is a legacy interface and might become deprecated, therefore I would like to avoid it so I don't have to rewrite this code in the near future. I'm unable to find another interface like download(url, filename) in standard libraries. If urlretrieve is considered a legacy interface in Python 3, what is the replacement? Deprecated is one thing, might become deprecated at some point in the future is another. If it

urllib.request in Python 2.7

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can use urllib.request module with Python 3.1. But when I execute the same program using Python 2.7, an error comes along the lines of; AttributeError: 'module' object has no attribute 'request'. I believe this error is because theres no request module in urllib for Python 2.7. Because I need to use tweepy i'll have to stick with Python 2.7 since tweepy does not support Python 3. So how I can use urllib.request module in Python 2.7? 回答1: use urllib2.urlopen 回答2: It is also possible to use six module to make code for both python2 & python3:

“No module named _scproxy” on OSX

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm on OSX 10.6 with pre-installed python 2.6 and would like to install python packages via easy_install or setup.py (in a downloaded package). In my case I'm trying to install MySQLdb. In both cases I get a stack trace which ends like so: ... File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/setuptools/command/easy_install.py", line 21, in <module> from setuptools.package_index import PackageIndex, parse_bdist_wininst File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/setuptools

urllib exception http.client.BadStatusLine

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I can't for the life of me figure out why I can't catch this exception. Looking here at this guide . def get_team_names(get_team_id_url, team_id): print(get_team_id_url + team_id) try: response = urllib.request.urlopen(get_team_id_url + team_id) except urllib.error.HTTPError as e: print(e.code) print(e.read()) except urllib.error.URLError as e: print(e.code) print(e.read()) exception: Traceback (most recent call last): File "queue_cleaner_main.py", line 60, in <module> sys.exit(main()) File "queue_cleaner_main.py", line 57, in main team

Python 3 - urllib, HTTP Error 407: Proxy Authentication Required

匿名 (未验证) 提交于 2019-12-03 00:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to open a website (I am behind a corporate proxy) using urllib.request.urlopen() but I am getting the error: urllib.error.HTTPError: HTTP Error 407: Proxy Authentication Required I can find the proxy in urllib.request.getproxies(), but how do I specify a username and password to use for it? I couldn't find the solution in the official docs. 回答1: import urllib.request as req proxy = req.ProxyHandler({'http': r'http://username:password@url:port'}) auth = req.HTTPBasicAuthHandler() opener = req.build_opener(proxy, auth, req