I\'m trying to request the html of a website using request but I keep getting an access denied error. How do I get past this? Here is the code for the function below:
<
You are getting a 403 Forbidden
because that website is blocking all requests sent using non common user agents (basically they check User-Agent
header). It is a very simple protection to avoid scrappers.
For example, if you send the following cURL using its standard User-Agent, the response is received perfectly:
curl -v 'https://www.jdsports.co.uk/product/green-nike-vapormax/281735/'
Nevertheless, if you repeat that request specifying a non existing User-Agent, the request is blocked:
curl -v 'https://www.jdsports.co.uk/product/green-nike-vapormax/281735/' -H 'User-Agent: StackOverflow'