This is probably because of mod_security
or some similar server security feature which blocks known spider/bot user agents (urllib
uses something like python urllib/3.3.0
, it’s easily detected). Try setting a known browser user agent with:
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()
This works for me.
By the way, in your code you are missing the ()
after .read
in the urlopen
line, but I think that it’s a typo.
TIP: since this is exercise, choose a different, non restrictive site. Maybe they are blocking urllib
for some reason…
Related Posts:
- Problem HTTP error 403 in Python 3 Web Scraping
- Should a 502 HTTP status code be used if a proxy receives no response at all?
- Web scraping redoc web api
- What is the difference between a URI, a URL and a URN?
- HTTP Status 504
- What is the difference between POST and GET? [duplicate]
- Do I need Content-Type: application/octet-stream for file download?
- application/x-www-form-urlencoded or multipart/form-data?
- application/x-www-form-urlencoded or multipart/form-data?
- Is 418 “I’m a teapot” really an HTTP response code?
- How to download a file over HTTP?
- How to define the basic HTTP authentication using cURL correctly?
- How to download a file over HTTP?
- How to define the basic HTTP authentication using cURL correctly?
- “Cannot GET /” with Connect on Node.js
- What is the meaning of [:] in python [duplicate]
- “CAUTION: provisional headers are shown” in Chrome debugger
- What’s the difference between a POST and a PUT HTTP REQUEST?
- How do I send a POST request with PHP?
- Why is it said that “HTTP is a stateless protocol”?
- What’s the difference between using application/csv vs text/csv? [duplicate]
- What are all the possible values for HTTP “Content-Type” header?
- How to find elements by class
- What is the difference between PUT, POST and PATCH?
- urllib2.HTTPError: HTTP Error 403: Forbidden
- What is the quickest way to HTTP GET in Python?
- What’s the difference between “Request Payload” vs “Form Data” as seen in Chrome dev tools Network tab
- Exception in thread “main” java.net.NoRouteToHostException: No route to host
- ndroid 8: Cleartext HTTP traffic not permitted
- How to save an image locally using Python whose URL address I already know?
- can we use XPath with BeautifulSoup?
- Can PHP cURL retrieve response headers AND body in a single request?
- Setting Curl’s Timeout in PHP
- How are parameters sent in an HTTP POST request?
- What should I use to open a url instead of urlopen in urllib3
- Why am I suddenly getting a “Blocked loading mixed active content” issue in Firefox?
- wget: unable to resolve host address `http’
- Are HTTP headers case-sensitive?
- When looking at the differences between X-Auth-Token vs Authorization headers, which is preferred?
- WordPress HTTP parameter pollution
- Does WordPress send data about your blog to WordPress.org or Automattic?
- Hiding WordPress REST API v2 endpoints from public viewing
- Does WordPress only support HTTP 1.1?
- How do I troubleshoot responses with WP HTTP API?
- Is curl required?
- The resource was preloaded using link preload but not used within a few seconds
- using wp_remote_get to retrieve own url on local host
- Using wp-cron in backpress – problems with wp_remote_post, fsockopen error
- Running index.php from command line & load balancer health checks
- Enable CORS in wordpress
- Change port of wordpress
- How to get value of custom http header?
- Several times request to load plugins when sending one request
- why is $_REQUESt[‘redirect_to’] empty?
- Get “HTTP/1.1 406 Not Acceptable” when accesing my website with Delphi Indy Control
- WordPress HTTP 500 Error “page isn’t working”
- What’s the point in having “www” in a URL?
- For what is the “.well-known”-folder?
- Human readable format for http headers with tcpdump
- How to make wireshark filter POST-requests only?
- Image file urls still point to http instead of https
- syntaxerror: “unexpected character after line continuation character in python” math
- ImportError: No module named pandas
- IndexError: too many indices for array
- TypeError: cannot unpack non-iterable NoneType object
- Where does pip install its packages?
- Python inline if statement
- how do you check your django version in cmd
- What does the /= operator mean in Python?
- Pandas, merging two dataframes on multiple columns, and multiplying result
- Are dictionaries ordered in Python 3.6+?
- Compiled vs. Interpreted Languages
- How to switch Python versions in Terminal?
- Forbidden (403) CSRF verification failed. Request aborted. Even using the {% csrf_token %}
- Playing mp3 song on python
- Unresolved reference issue in PyCharm
- How to use 2to3 properly for python?
- Is there a way to return literally nothing in python?
- Is there a built-in function to print all the current properties and values of an object?
- Image.open() cannot identify image file – Python?
- python socket programming OSError: [WinError 10038] an operation was attempted on something that is not a socket
- Multiple try codes in one block
- Python 3: Multiply a vector by a matrix without NumPy
- How to fix “Can’t find a default Python” error
- TypeError: ‘newline’ is an invalid keyword argument for this function
- datetime to string with series in pandas
- Is it possible only to declare a variable without assigning any value in Python?
- How to Install pip for python 3.7 on Ubuntu 18?
- How to add a new row to an empty numpy array
- How to make a python script wait for a pressed key?
- TypeError: Image data can not convert to float
- Mean Squared Error in Numpy?
- Turn a single number into single digits Python
- Converting a list to a set changes element order
- Create a list with initial capacity in Python
- Accessing dict_keys element by index in Python3
- How to update Pandas from Anaconda and is it possible to use eclipse with this last
- Does python support character type?
- Moving site from HTTP to HTTPS
- Duplicator live to wamp https to http