我把这个脚本放到了IDLE 2.7.14
import urllib2
from bs4 import BeautifulSoup
quote_page = 'http:www.bloomberg.com/quote/SPX:IND'
page = urllib2.urlopen(quote_page)
回溯:
追踪(最近一次呼叫最后一次):
"/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:我安装并卸载了BeautifulSoup,Pycharm,并且之前下载了Python 2x ......
答案 0 :(得分:1)
您的网址格式不正确。它应该是:
quote_page = 'http://www.bloomberg.com/quote/SPX:IND'