본문 바로가기

selenium4

Python 크롤링 스샷 스크린샷 캡쳐 selenium 이 필요합니다 pip install selenium 노션 캡쳐를 예쁘게 하고 싶어서 이렇게 시작했어요~ from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By DRIVER = './chromedriver'.. 2020. 10. 24.
Python Selenium 창 사이즈 설정하기 크롤링 하면서 창 사이즈를 조절해야 하는 경우가 있어요 headless를 설정해서 화면이 보이지 않도록 할 수 있는데요 headless 옵션으로 모니터 화면보다 셀레니움에서 크게 화면을 설정해볼 수 있어요 from selenium import webdriver chrome_options = Options() chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN") chrome_options.add_argument("--headless") driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"),options=chrome_options) driver.set_w.. 2020. 10. 23.
Python 크롤링 selenium 자바스크립트 결과 값 받기 자바스크리트를 실행하고 결과를 Python으로 가져와서 활용하는 방법입니다 >>> from selenium import webdriver >>> driver = webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH")) >>> driver.get("http://접속주소") >>> driver.execute_script("return 5") 5 >>> driver.execute_script("return true") True >>> driver.execute_script("return {j: '값'}") {u'foo': u'bar'} >>> driver.execute_script("return func()") u'func 함수 실행 결과' .. 2020. 10. 22.
Heroku 서비스에서 Selenium Python 크롤링하기 파이썬에서 Selenium 이용하여 크롤링하려면 크롬이 필요해요 노트북에서는 그냥 다운로드하여서 설치하면 되는데 헤로쿠에서 사용하려면 빌드팩을 설정하면 가능합니다 명령어로 할 수도 있는데 웹에서 작업하는게 편하더라고요 Heroku 에서 로그인해서 원하는 프로그램을 선택하고 Settings으로 가면 Buildpacks 부분에서 설정할 수 있어요 파이썬 어플을 만들고 있었다면 heroku/python 이 기본적으로 있을 텐데요 크롬을 설치하기 위해서 Add buildpack을 눌러서 2개를 추가해주세요 # 구글 크롬 https://github.com/heroku/heroku-buildpack-google-chrome ## 크롬 드라이버 https://github.com/heroku/heroku-buildpa.. 2020. 10. 17.
반응형