If you give the invalid URL path, it will return the 404 “file not found” status code.

I was working on one of the Python Django projects for developing the online SEO (Search Engine Optimization) tool. In that project, I had to check whether a particular link (backlink) is present in the given web page URL or not.

How to check backlink in Python? (Backlink Checker Tool)

We are writing check_backlink() function which will return -1 if the backlink is not present in the given URL. Otherwise, it returns a positive integer that is an index of the first matching backlink.

Note:find() is a string method that returns the index of the first matching string. If the given string is not present, it returns -1.

Based on the response from the check_backlink() method, an appropriate message is printed using the if-else statement.

I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.