imsanjoykb / Data-Science-Regular-Bootcamp

Regular practice on Data Science, Machien Learning, Deep Learning, Solving ML Project problem, Analytical Issue. Regular boost up my knowledge. The goal is to help learner with learning resource on Data Science filed.
https://imsanjoykb.github.io/
MIT License
106 stars 40 forks source link

Data ScrPing error handling using beautifulsoup4. #167

Open imsanjoykb opened 2 years ago

imsanjoykb commented 2 years ago
import requests

from urllib.error import HTTPError

url = 'https://www.geeksforgeeks.org/implementing-web-scraping-python-beautiful-soup/amp/'

try:

    response = requests.get(url)

    response.raise_for_status()

except HTTPError as hp:

    print(hp)

else:
print("it's worked")