'python AsyncHTMLSession: You don't have permission to access "XXX" on this server

I want to access a site with python using AsyncHTMLSession from requests_html library.
This is my code:

from requests_html import AsyncHTMLSession
import asyncio

async def connect_to_site(url):
    session = AsyncHTMLSession()
    headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"}
    res = await session.get(url, headers=headers)
    print(res)
    await res.html.arender(sleep=5, timeout=30)
    print(res.html.full_text)

url = 'https://www.otcmarkets.com'

asyncio.run(connect_to_site(url))

After executing the code, I get the following print:

<Response [200]>
Access Denied
Access Denied
You don't have permission to access "http://www.otcmarkets.com/" on this server.
Reference #18.9c4519d4.1643149046.338b64e3

What could be the issue? and how can I overcome it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source