728x90 ๋ฐ์ํ ๐จ๐ผ๐ป๊ฐ๋ฐ/์ ๋ ๋์37 ์ ๋ ๋์ - ์์ ๊ฐ์ด๋ฐ๋ก ์คํฌ๋กคํ๊ธฐ element = driver.find_element_by_xpath('//*[text()="์ฌ์ฉ๊ฐ ์์"]')scrollElementIntoMiddle = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);"\ + "var elementTop = arguments[0].getBoundingClientRect().top;"\ + "window.scrollBy(0, elementTop-(viewPortHeight/2));";\driver.execute.. 2024. 5. 23. ์ ๋ ๋์ - URL ์ฐ๊ฒฐ ์์ฒญ ์ฐจ๋จ ํ์ฅ ๋๊ตฌ(HTTP Request Blocker) https://chromewebstore.google.com/detail/http-request-blocker/eckpjmeijpoipmldfbckahppeonkoeko?hl=en-US HTTP Request BlockerThis extension blocks HTTP Request based on configurable URL patterns.chromewebstore.google.com ์ถ์ฒ : https://stackoverflow.com/questions/27863094/how-to-block-a-url-in-chromes-developer-tools-network-monitor How to block a URL in Chrome's developer tools network monitorI .. 2024. 4. 26. ์ ๋ ๋์ - ์ ํญ ์ด๊ธฐ & ์ ์ฐฝ ์ด๊ธฐ driver.switch_to.new_window('tab') driver.switch_to.new_window('window') 2023. 10. 5. ์ ๋ ๋์ - ํน์ ํ๊ทธ ๋ฒ์ ํ์ํ๊ธฐ driver.execute_script("arguments[0].style.border='2px solid red';", elem) # ํ๊ทธ ๋ฒ์ ํ์ 2023. 7. 29. ์ ๋ ๋์ - ์์ง ์์ฌ๋ผ์จ ํฌ๋กฌ๋๋ผ์ด๋ธ ์ต์ ๋ฒ์ ์ค์นํ๊ธฐ https://googlechromelabs.github.io/chrome-for-testing/ Chrome for Testing availability This page lists the latest available cross-platform Chrome for Testing versions and assets per Chrome release channel. Consult our JSON API endpoints if you’re looking to build automated scripts based on Chrome for Testing release data. Last updated @ 20 googlechromelabs.github.io 2023. 7. 28. ์ ๋ ๋์ - html ์์๋ ํฌํจํด์ ํ ์คํธ ๋ณต์ฌํ๊ธฐ(klembord) example.py import time import klembord from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains options = Options() options.add_argument("--headless") options.add_argument("--disable-gpu") options.add_argument("--no-sandbox") options.add_argument("--disable.. 2023. 7. 23. ์ ๋ ๋์ - ํฌ๋กฌ ๋ค์ด๊ทธ๋ ์ด๋ ๋ง์ฝ ํฌ๋กฌ๋๋ผ์ด๋ธ๊ฐ ํ์ฌ ์ปดํจํฐ์ ์ค์น๋ ์ต์ ๋ฒ์ (chrome://version์์ ํ์ธ ๊ฐ๋ฅ)์ ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ ๊ธฐ์กด ํฌ๋กฌ์ ์ญ์ ํด์ ๋ฎ์ ๋ฒ์ ์ผ๋ก ์ค์นํ๋ ๋ค์ด๊ทธ๋ ์ด๋๊ฐ ํ์ํจ ํฌ๋กฌ ๋ฒ์ ๋ณ ๋ค์ด๋ก๋ ๋ชจ์ ์ฌ์ดํธ(uptodown) https://google-chrome.en.uptodown.com/windows/versions Older versions of Google Chrome (Windows) | Uptodown exe 115.0.5790.99 Jul 19, 2023 exe 114.0.5735.199 Jun 28, 2023 zip 114.0.5735.134 Jun 16, 2023 zip 114.0.5735.106 Jun 7, 2023 exe 113.0.5672.127 May 29, 2023.. 2023. 7. 22. ์ ๋ ๋์ - xpath ์๋ฐ์คํฌ๋ฆฝํธ๋ก ํด๋ฆญํ๊ธฐ (javascript error: $x is not defined) ๋ฐฉ๋ฒ 1. marketplace_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(), "Marketplace")]'))) marketplace_button.click() ๋ฐฉ๋ฒ 2. marketplace_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(), "Marketplace")]'))) driver.execute_script("arguments[0].click();", marketplace_button) ์ถ์ฒ: https://stackove.. 2023. 6. 11. ์ ๋ ๋์ - xpath, ํ ์คํธ๊ฐ ํฌํจ๋ ์์ ์ ํ(contains text) ์ํ๋ ๋ฌธ์์ด์ธ ์์ ์ฐพ๊ธฐ ex) ์์์ ๋ด์ฉ์ด foo์ธ ๊ฒ์ ์ฐพ๊ธฐ //myparent/mychild[text() = 'foo'] ์ํ๋ ๋ฌธ์์ด์ด ํฌํจํ(contains) ์์ ์ฐพ๊ธฐ ex) ABC๋ผ๋ ๋ด์ฉ์ ํฌํจํ ์๋ ์์ ์ฐพ๊ธฐ //*[contains(text(),'ABC')] ํ์ด์ฌ ์ฌ์ฉ ์์ driver.find_element_by_xpath('//span[contains(text(),"ABC")]') ์๋ฐ์คํฌ๋ฆฝํธ(๋ธ๋ผ์ฐ์ ๊ฐ๋ฐ์ ๋๊ตฌ) ์ฌ์ฉ ์์ $x("//*[contains(text(),'12:00')]") ๊ทธ ๋ฌธ์์ธ ๊ฒ์ ์ฐพ๊ธฐ $x('//*[text()="๋ค์ด๋ฒ๋ก ์ด์ฉํ๊ธฐ"]') ์์ฑ(class๋ id) ๊ฐ์ด ํน์ ๋ฌธ์๋ก ์์ํ๋ ์์ ์ฐพ๊ธฐ $x("//div[starts-with(@class,.. 2023. 5. 7. ์ ๋ ๋์ - ํฌ๋กฌ๋๋ผ์ด๋ธ ์๋ ์ค์น ๋ชจ๋ ์ค์น pip install webdriver_manager from webdriver_manager.chrome import ChromeDriverManager def exec_chrom(): driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) return driver 2023. 3. 8. ์ ๋ ๋์ - ์ด๋ฏธ์ง(img) ๋ค์ด๋ก๋ (No urllib.urlretrieve) URL ์์ฒญ ๋ฐฉ์์ธ urllib.urlretrieve์ src ์ฃผ์๋ก ์์ฒญ์ ํ๋ ๋ฐฉ์์ด๊ธฐ ๋๋ฌธ์ ์บก์ฑ (์๋๋ฑ๋ก๋ฐฉ์ง ๋ฌธ์)์ฒ๋ผ ๋งค๋ฒ ์์ฒญํ ๋๋ง๋ค ์ด๋ฏธ์ง๊ฐ ๋ฐ๋๋ ๊ฒฝ์ฐ๊ฐ ์์ด ๋ฌด์ฉ์ง๋ฌผ์ด ๋๋ค. ๊ทธ๋ฌ๋ฏ๋ก ์ด๋ฏธ ๋ธ๋ผ์ฐ์ ์ ๋ก๋๊ฐ ๋ ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ ธ์ค๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํด์ผ ํ๋ค. ๋ฐฉ๋ฒ 1. screenshot_as_png ์ฌ์ฉ (์ถ์ฒ) from selenium import webdriver driver = webdriver.Firefox() driver.get('https://www.webpagetest.org/') with open('filename.png', 'wb') as file: file.write(driver.find_element_by_xpath('/html/body/div[1]/div[5]/div[2.. 2023. 2. 28. ์ ๋ ๋์ - ํ์ด์ฌ ๋ด ๊ฐ์ง ์ฐํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ(undetected-chromdriver) pypi https://pypi.org/project/undetected-chromedriver/ undetected-chromedriver ('Selenium.webdriver.Chrome replacement with compatiblity for Brave, and other Chromium based browsers.', 'Not triggered by CloudFlare/Imperva/hCaptcha and such.', 'NOTE: results may vary due to many factors. No guarantees are given, except for ongoing eff pypi.org ์ค์น pip install undetected-chromedriver ์ฌ์ฉ ์์ import u.. 2023. 1. 29. ์ด์ 1 2 3 4 ๋ค์ 728x90 ๋ฐ์ํ