urllib.error.HTTPError: HTTP Error 403: Forbidden code example
Example 1: urllib.error.HTTPError: HTTP Error 403: Forbidden
from urllib.request import Request, urlopen
req = Request('http://www.cmegroup.com/trading/products/#sortField=oi&sortAsc=false&venues=3&page=1&cleared=1&group=1', headers={'User-Agent': 'Mozilla/5.0'})
webpage = urlopen(req).read()
Example 2: 403 forbidden
HTTP 403 is a HTTP status code meaning access to the requested resource is forbidden for some reason.
Example 3: error 403
// Don't be on a forbidden page!!