<s>[INST] from bs4 import BeautifulSoup
import requests
import sqlite3

# make a request to the url
response = requests.get('https://web.archive.org/web/20211020053347/http://example.com/')
soup = BeautifulSoup(response.content, 'html.parser')

# find all "a" tags
links = soup.find_all('a')

# create empty list
shortenedากlinks = []

# loop through all links to see if they contain a "=" after the .com/
for link in links:
    href = link.get('href')

    # check if the link is not None
    if href is not None:
        # check broken link
        if href.startswith('/'):
           href = "https://web.archive.org/web/20211020053347/http://example.com/" + href

        # add trailing / if no Matches
        if href.endswith("/"):
            continue
        if not href.endswith("=") and href.endswith("/") is False:
            href = href + '='

        # shorten the link if it's on example.com and has "=" after the .com/
        if href.find("=".format("/")) is not -1:
            parts = href.split("=")

            if len(parts) is 3:
               shortenedlink = parts[0] + '//' + parts[1]
               shortenedlink = shortenedlink.split('/')
               shortenedlink = "https://"+shortenedlink[-1] + href[-1]

            elif len(parts) is 2:
               shortenedlink = "https://" + href.split("/")[2] + "="

                 # Add to list 
        shortenedakislinks.append(shortenedlink)

# Total shortened links        
 print ("Total shortened links:", len(shortenedakislinks))
 
#Push result to database
 conn = sqlite3.connect('_1_direct_deduct_sql.db') 
 c = conn.cursor()
 c.executemany('INSERT INTO comm.clientdetails VALUES(?[/INST]