Oct-04-2018, 11:03 AM
Some sites require you to provide a header (user-agent) in your request, and may refuse your connection otherwise.
you can find your user-agent by googleing 'my user agent', it will appear at top of page,
then set up in dictionary like:
you can find your user-agent by googleing 'my user agent', it will appear at top of page,
then set up in dictionary like:
user_agent = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) ' 'Gecko/20100101 Firefox/60.0 AppleWebKit/537.36 (KHTML, ' 'like Gecko) Chrome/68.0.3440.75 Safari/537.36'}don't know what you are using to get page, but with requests it would be:
response = requests.get(url, headers=user_agent)Also make sure you are sleeping for a few seconds after each request as hammering on a site is another reason for refusal.
from time import sleep ... response = requests.get(url, headers=user_agent) sleep(2)