본문 바로가기

분류 전체보기21

Python) 멀티프로세싱을 이용한 selenium 웹크롤링 # -*- coding: utf-8 -*- import sys import os import subprocess import time import multiprocessing from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.alert import Alert from selenium.webdriver.common.by import By from sel.. 2022. 2. 3.
Python) 멀티프로세싱 모듈 사용법 (Process, Pool) import multiprocessing # --- --- multiprocessing.Process 사용 def do_multi(code): # main에서 지정한 code_list의 1,2 각각 들어와서 # 두 개의 프로세스가 실행 # 여기 do_multi 함수에 멀티프로세싱으로 실행할 코드를 작성하면됨. print (code) #------------------------------------------------------------ def main(): processes = [] code_list = [1,2] for code in code_list: # 실행함수, 파라미터(복수개 가능) p = multiprocessing.Process(target = do_multi, args = [code,.. 2022. 1. 24.
selenium) 라디오버튼 값 얻기 .get_attribute # 1번 라디오버튼이 클릭 되어있는지 true or false radio_value = driver.find_element_by_xpath('xpath').get_attribute("checked") >>> print (radio_value) >>> true # value 값 얻기 radio_value = driver.find_element_by_xpath('xpath').get_attribute("value") >>> print (radio_value) >>> 1번버튼 2022. 1. 17.
selenium) 셀레니움 xpath 클릭 안될때 JavaScript 이용 방법 # 기본적인 방법 driver.find_element_by_xpath('xpath').click() # 자바스크립트를 이용한 방법 # 1. element = driver.find_element_by_xpath('xpath') driver.execute_script("arguments[0].click();", element) # 2. 자바스크립트 문법 & html id 이용 driver.execute_script("document.querySelector('#btnSearch').click()") 2022. 1. 17.