Check if a page has a backlink on it using Python

I found a guy’s project on GitHub where he already built the tool for checking backlinks. To use this tool, you need to provide a text file that contains the referring domain and the destination URL. They need to be side by side in their own row. Each referring domain is scraped and searched.,,

The full source can be found on the GitHub page linked above, or just see it below. Here is what it does:

  1. Set up credentials for web browsing
  2. Create an empty list to store URLs
  3. Pull URLs from text file
  4. Split the comma separated URLs for each row in the document
  5. Visit the referring domain’s web page
  6. Parse the HTML and scan it for any mention of the destination URL
  7. Return true or false
import requests
import time

headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}

not_found = []
to_check = open('urls.txt', 'r+')
for check in
    do_check = check.split(',')
    print("---checking ", do_check[0])
    r = requests.get(do_check[0], headers=headers)
    if do_check[1] in r.text:
        print("---", do_check[1], " not found on ", do_check[0])
print(len(not_found), " Link not found")
Leave your thoughts below. Follow on Twitter