Adding try except block in case of connection errors
This commit is contained in:
parent
fbdfdc287b
commit
2f69f1d3b6
|
@ -35,7 +35,10 @@ class Crawler:
|
|||
return articles
|
||||
|
||||
def __download_url__(self, url):
|
||||
return requests.get(url, headers=HEADERS).text
|
||||
try:
|
||||
return requests.get(url, headers=HEADERS).text
|
||||
except requests.exceptions.ConnectionError:
|
||||
print('An error has occured trying to download the HTML')
|
||||
|
||||
def __extract_article_urls__(self, source) -> []:
|
||||
soup = BeautifulSoup(source, 'html.parser')
|
||||
|
|
Loading…
Reference in New Issue
Block a user