Untitled
unknown
python
2 years ago
1.3 kB
8
Indexable
from selenium import webdriver
import mysql.connector
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
options = webdriver.ChromeOptions()
options.add_argument("user-agent=Mozilla/5.0 (Linux NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")
driver = webdriver.Chrome(options=options)
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="Harlyonok123!",
database="lastMainDbLiquipedia"
)
mycursor = mydb.cursor()
mycursor.execute("SELECT `HLTV_matchpage_link` FROM matches WHERE `HLTV_matchpage_link` IS NOT NULL")
myresult = mycursor.fetchall()
i = 1
for link in myresult:
print(i)
print(link[0])
driver.get(link[0])
if "Проверка безопасности подключения к сайту" in driver.page_source:
# Wait for a few seconds and retry
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it(
(By.CSS_SELECTOR, "iframe[title='Widget containing a Cloudflare security challenge']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "label.ctp-checkbox-label"))).click()
time.sleep(15)
i += 1Editor is loading...