0
import requests
headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", 
    "Accept-Encoding": "gzip, deflate", 
    "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8", 
    "Dnt": "1", 
    "Host": "httpbin.org", 
    "Upgrade-Insecure-Requests": "1", 
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0", 
  }
url="https://app.shkolo.bg/dashboard"
res = requests.get(url,headers=headers)
print(res)

This throws a 403 response. Any idea why? I've just starting using the requests module so I cannot much more information.

1 Answers1

0

By removing all information except the User-Agent I managed to get the reply:

import requests

url = "https://app.shkolo.bg/dashboard"
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0'}
result = requests.get(url, headers=headers)
print(result.content.decode())


# Begin of the output
<!DOCTYPE HTML>
<html lang="en-US">
<head>
  <meta charset="UTF-8" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Note that the answer is completely similar to this post.

Thymen
  • 2,089
  • 1
  • 9
  • 13
  • But it still gives a 503 response? – Pipas sin sal Dec 03 '20 at 22:29
  • I checked the return body, it says: `Access denied`. This might be based on a cloudflare block. In that case there is little hope of doing this programmetically using requests, as explained in [this](https://stackoverflow.com/questions/49087990/python-request-being-blocked-by-cloudflare) post. A possible alternative could be using [selenium](https://selenium-python.readthedocs.io/) with a headless driver. This will add a bit more overhead, but can bypass it. – Thymen Dec 04 '20 at 14:47