Skip to content Skip to sidebar Skip to footer

My Code Returns Http Error 403: Forbidden

from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup myUrl = 'https://mee6.xyz/levels/159962941502783488' uClient = uReq(myUrl) pageHtml = uClient.rea

Solution 1:

You are being blocked because of your User Agent. Try spoofing your User Agent like this:

from urllib.request import urlopen as uReq
from urllib.request import Request
from bs4 import BeautifulSoup as soup

myUrl = "https://mee6.xyz/levels/159962941502783488"

req = Request(
    myUrl, 
    data=None, 
    headers={
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
    }
)

uClient = uReq(req)
pageHtml = uClient.read()
print(pageHtml)

Post a Comment for "My Code Returns Http Error 403: Forbidden"