I am trying to scrape the following web page https://jamanetwork.com/journals/jamaneurology/article-abstract/2696970 but getting an error.
url ='https://jamanetwork.com/journals/jamaneurology/article-abstract/2696970'
result = requests.get(url)
soup = BeautifulSoup(result.content, 'html.parser')
print(soup.prettify())
Result:
403 Forbidden
Request forbidden by administrative rules.
You can access the web page with no credentials, so not sure why I get 'Request forbidden' error while scraping.
As mentioned you should add a
user-agentto your request:You can check your own headers, send by the browser via opening dev tools and take a look under network section. Read more about
user-agent.Example