I Try to get a query form my sql and use that value for searching element in page via bs4 and i use some While loop and if statemet , and at the first runing of code it get query from DB and using the 0th element of the query list then check in the page and if the value isn't in the page i use the try , except and in the exception , useing the if statement that check if the torrent_link_num is equal to 0 change the value of torrent_link_num to 1 and make the second while loop restart and get the 1th element of query list for seraching but the issue is , while_stat = True in the if statement dose not workig
here is my code :
torrent_link_num = 0
while True:
while_stat =True
while while_stat:
lucas_db = mysql.connector.connect(
host='1.1.1.1',
user="zzzzz",
password="xxxxx",
database="Lucas_database")
mycursor_torrent_link = lucas_db.cursor()
mycursor_torrent_link.execute("SELECT ipt_torrent_link FROM Lucas_t_db ORDER BY Published_Time DESC LIMIT 10")
myresult_torrent_link = mycursor_torrent_link.fetchall()
print(">>>> length of Tv packs banned in Database : ", len(myresult_torrent_link))
torrent_link = [a[0] for a in myresult_torrent_link]
print(torrent_link_num)
torrent_link = torrent_link[torrent_link_num]
print(">>>> Torrent Link DB value ",torrent_link)
if torrent_link == None:
print("no Torrent links in db")
torrent_link = input("enter the First Torrent Link For start ::::")
# driver.find_element_by_xpath('//*[@id="iptStart"]/div[3]/a[1]').click() # this or
driver.refresh() # this ?
my_driver = driver.page_source
my_soup = Wsoup(my_driver, "html.parser")
# try:
torrent_link = torrent_link.replace("https://iptorrents.com/details.php?","")
torrent_link = torrent_link.replace("/details.php?","")
print(torrent_link)
last_rls = my_soup.body.tbody.tr.td.find('a' , attrs={'href':re.compile(torrent_link)})
try:
Entry= last_rls.parent
print("x")
except AttributeError:
print("error while founding previous rls")
if torrent_link_num == 0:
print("10101010")
torrent_link_num = 1
while_stat =True
except AttributeError:
print("zz")
driver.find_element_by_xpath('//*[@id="body"]/tbody/tr/td/div[2]/div[1]/span/div[2]/a').click()
while_stat =True
found_t = Entry.parent.find_previous_sibling('tr')
Aucun commentaire:
Enregistrer un commentaire