목록Coding/Python (55)
0w0
ref. https://selenium-python.readthedocs.io/waits.html 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Implicitly wait - 코드 : bs_driver.implicitly_wait(10) - 코드 설명 : 브라우저 드라이버가 페이지 호출을 10초 이내 동안 대기해주는 것 - 암시적 대기, 웹 페이지가 시간 내에 로딩되도록 대기하는 방식. - "No such Element Exception"이 발생하기 전에 웹 드라이버에게 특정 시간 동안 대기하도록 지시. Explicitly wait - from selenium.webdriver.common.by import By - from sel..
#함수 형태로 thread 적용 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import threading import time def thread_run(): print('Thread running -Test') def thread_run_msg(msg): print('Thread running -Test',msg) start_time=time.time() for i in range(1000): t1=threading.Thread(target=thread_run) t2=threading.Thread(target=thread_run_msg,args=('service',)) t1.start() t2.start() print(time.time()-st..
보호되어 있는 글입니다.
ref. https://intellipaat.com/blog/tutorial/selenium-tutorial/selenium-cheat-sheet/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import sys,io,time from bs4 import BeautifulSoup #requests 모듈 사용 import requests html=requests.get('https://search.naver.com/search.naver?query=날씨') soup=BeautifulSoup (html.text,'html.parser') data1 = soup.find('span',{'class':'todaytemp'}) print("현재온도:", data1.text) print("==============================") #urll..
12345678910111213141516171819202122232425262728293031323334353637383940414243#coding=utf-8 import sys, io, timeimport urllib.request as urqimport urllib.parsefrom bs4 import BeautifulSoup #--구글 html 소스 파싱html=urq.urlopen('https://www.google.com/').read() #--파싱된 소스를 BeautifulSoup 적용soup=BeautifulSoup(html,'html.parser') print("#--태그로 find_all")#모든 div 태그를 가져와 리스트 형태 저장div_all=soup.find_all('div')..
ip API json데이터 가져오기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 import urllib.request as req from urllib.parse import urlencode #호스트 및 API 페이지 init_url="https://api.ipify.org" values={ 'format':'json' } print('before:',values) params=urlencode(values) print('after :',params) print() req_url=init_url+'?'+params print('요청url',req_url) data=req.urlopen(req_url).rea..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #http://zzzscore.com/color/ import sys, io, time from selenium import webdriver from collections import Counter bs_driver=webdriver.Chrome('C:\Workspace\webdriver\chrome\chromedriver') bs_driver.get('http://zzzscore.com/color/#') def click_color(): bs_driver.find_element_by_class_name('main').click() #main start_time=time.time() while time.time(..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #http://zzzscore.com/color/# import sys, io, time from selenium import webdriver from collections import Counter bs_driver=webdriver.Chrome('C:\Workspace\webdriver\chrome\chromedriver') bs_driver.get('http://zzzscore.com/color/#') btns=bs_driver.find_elements_..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #http://zzzscore.com/1to50/?ts=1565704612997 import sys,io,time from selenium import webdriver bs_driver=webdriver.Chrome('C:\Workspace\webdriver\chrome\chromedriver') bs_driver.get('http://zzzscore.com/1to50/?ts=1565704612997') num=1 while num