DEV Community

Free Python Code
Free Python Code

Posted on • Edited on

A simple Python script to check for broken links

πŸ™‚πŸ–

In this post, I will share with you how to make A simple Python script to check for broken links.

You can use it on your website to check for broken links.

In this post I will test this script on my API πŸ€—

 import requests bad_links = [] def check_link(link): res = requests.get(link) if res.status_code == 200: print('working') else: print('not working') bad_links.append(link) links = [ 'http://127.0.0.1:8000/', 'http://127.0.0.1:8000/test1', 'http://127.0.0.1:8000/test2' ] for link in links: check_link(link) 
Enter fullscreen mode Exit fullscreen mode

result

working not working not working 
Enter fullscreen mode Exit fullscreen mode

Now we're done πŸ€—

Don't forget to like and follow πŸ™‚

Support me on PayPal πŸ€—
https://www.paypal.com/paypalme/amr396

Top comments (0)