简体   繁体   English

空闲文本编辑器/Python2.7/Mac OS X/&quot;URLError:<urlopen error no host given> ”

[英]IDLE text editor/Python2.7/Mac OS X/ "URLError: <urlopen error no host given>"

I put in this script to IDLE 2.7.14我把这个脚本放到了 IDLE 2.7.14

import urllib2
from bs4 import BeautifulSoup
quote_page = 'http:www.bloomberg.com/quote/SPX:IND'
page = urllib2.urlopen(quote_page)

Traceback:追溯:

Traceback (most recent call last):回溯(最近一次调用最后一次):

"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py
", line 1126, in do_request_
    raise URLError('no host given')
URLError: <urlopen error no host given>
>>> 

Backstory: I installed and uninstalled BeautifulSoup, Pycharm, and downloaded Python 2x earlier...背景故事:我安装并卸载了 BeautifulSoup、Pycharm,并较早下载了 Python 2x...

Your URL is incorrectly formed.您的网址格式不正确。 It should be:它应该是:

quote_page = 'http://www.bloomberg.com/quote/SPX:IND'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 2.7忽略URLError: <urlopen error [Errno 113] No route to host> - Python 2.7 ignore URLError: <urlopen error [Errno 113] No route to host> urllib.error.URLError: <urlopen error no host given> python 3 - urllib.error.URLError: <urlopen error no host given> python 3 用Mock编写Python2.7单元测试(URLError: <urlopen error unknown url type: http> ) - Writing Python2.7 unittest with Mock (URLError: <urlopen error unknown url type: http>) urllib2.URLError: urlopen 错误没有给出主机 - urllib2.URLError: urlopen error no host given urlib错误:“ urllib.error.URLError: <urlopen error no host given> ” - urlib error: “urllib.error.URLError: <urlopen error no host given>” 在python中打开html:urllib.error.URLError: <urlopen error no host given> - open html in python: urllib.error.URLError: <urlopen error no host given> 在Mac OS X上运行“python”和“python2.7”有什么区别? - What is the difference between running “python” and “python2.7” on a Mac OS X? 无法安装reportlab mac OS X 10.9.2 + python2.7 - can't install reportlab mac OS X 10.9.2 + python2.7 Pandas:read_json urllib.error.URLError:<urlopen error no host given> , 用于工作的代码</urlopen> - Pandas: read_json urllib.error.URLError: <urlopen error no host given>, code used to work MAC OS 上的 root 用户将 python2.7 更改为 python3.7 - Change python2.7 to python3.7 for root on MAC OS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM