Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- def getting_url():
- try:
- url = input("Type url that you want to crawl (example - https://blablabla.com): ").replace(" ", "")
- if "https" not in url or "http" not in url:
- print("You need to specify protocol of the page")
- getting_url()
- else:
- if "://www." in url:
- final_url = url.replace("www.", "")
- if ".com" in url:
- r = requests.head(final_url)
- if r.status_code == 200:
- return final_url
- else:
- print("Url doesn't exist")
- else:
- print("Url is not valid.")
- getting_url()
- else:
- if ".com" in url:
- r = requests.head(url)
- if r.status_code == 200:
- return url
- else:
- print("Url doesn't exist")
- else:
- print("Url is not valid.")
- getting_url()
- except KeyboardInterrupt:
- print("\nQuiting")
- except:
- print("Url doesn't exist")
- getting_url()
- print(getting_url())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement