0

I am new to python and I am trying to scrape a website following a tutorial and the code goes as follows:

from urllib.request import urlopen as uReq
url = 'https://www.example.com/'
uClient = uReq(url)

The last line provides an error as the website needs authentication first. How to I get around this?

  • What scheme is the website using [see here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes). Authentication is usually set via headers. See [this](https://stackoverflow.com/a/7933546/14759164) for how to set headers with urllib. – Ali Samji Mar 30 '21 at 17:43
  • If you could post the error-message (HTTP-response) you got, there would be a better chance to help you authenticating the proper way. – hc_dev Mar 30 '21 at 17:44
  • the error I got is as follows: `urllib.error.HTTPError: HTTP Error 403: Forbidden` – Faress Eissa Mar 31 '21 at 12:25

0 Answers0