Artificial intelligent assistant

Python3でwebスクレイピングしたいのですが存在するURLが開けません。 python3BeautifulSoupweb > urllib.error.HTTPError: HTTP Error 403: Forbidden def RichestSchool(): """get 100 richest school names """ html = urlopen(" bsObj = BeautifulSoup(html, "lxml") for rich in bsObj.findAll("a", {"target":"_blank"}): riches = rich.get_text() print(riches)

metropolis
Firefox


#!/usr/bin/python3
import urllib.request

url = "
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0",
}

request = urllib.request.Request(url=url, headers=headers)
response = urllib.request.urlopen(request)
html = response.read().decode('utf-8')
print(html)


robts.txt

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy c41e907b566cb08503314681081f3cb4