Last active
June 6, 2023 01:23
-
-
Save seiwonpark/fad4b9b96390d181f56738da9adc4f4f to your computer and use it in GitHub Desktop.
python crawler base code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.support.ui import WebDriverWait | |
from webdriver_manager.chrome import ChromeDriverManager | |
class Crawler: | |
def __init__(self): | |
self.SERVICE = Service(ChromeDriverManager().install()) | |
webdriver_options = webdriver.ChromeOptions() | |
webdriver_options.add_argument("headless") | |
self.driver = webdriver.Chrome(service=self.SERVICE, options=webdriver_options) | |
def driver_find_xpath(self, path: str): | |
return self.driver.find_element(By.XPATH, path) | |
def web_driver_wait_xpath(self, path: str): | |
return WebDriverWait(self.driver, 5).until( | |
EC.visibility_of_element_located((By.XPATH, path)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment