설치하기
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# 다운로드 받은 .deb 파일을 설치
sudo dpkg -i google-chrome-stable_current_amd64.deb
# 만약 의존성 문제로 설치가 중단된 경우 의존성 문제를 해결하고 설치를 완료
sudo apt --fix-broken install
소스코드
우분투 기반 headless Selenium 드라이버 소스코드 이다.
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
## WINDOWS
from webdriver_manager.chrome import ChromeDriverManager
import twitter_scraper
def call_webpage_periodically(driver):
driver.get('https://x.com')
time.sleep(5)
driver.save_screenshot("02.webpage.png")
time.sleep(300)
def init_win():
options = webdriver.ChromeOptions()
# options.add_argument('headless')
############################
options.add_argument('window-size=1920,1080')
options.add_argument('disable-gpu')
options.add_argument("lang=ko_KR")
options.add_argument(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")
####################################################################
# Windows Version
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
# Ubuntu Version
# service = Service(executable_path='/root/chromedriver-linux64/chromedriver')
# driver = webdriver.Chrome(service=service, options=options)
####################################################################
twitter_scraper.input_id(driver, '+821054611785')
twitter_scraper.input_password(driver, 'gosoTekzhRlfl1!')
driver.save_screenshot("00.login.png")
return driver
def init_ubuntu():
options = webdriver.ChromeOptions()
options.add_argument('headless')
# Ubunti Options #
options.add_argument('--headless')
options.add_argument('--no-sandbox')
############################
options.add_argument('window-size=1920,1080')
options.add_argument('disable-gpu')
options.add_argument("lang=ko_KR")
options.add_argument(
"user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")
####################################################################
# Windows Version
# driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
# Ubuntu Version
service = Service(executable_path='/root/chromedriver-linux64/chromedriver')
driver = webdriver.Chrome(service=service, options=options)
####################################################################
twitter_scraper.input_id(driver, '+821054611785')
twitter_scraper.input_password(driver, 'gosoTekzhRlfl1!')
driver.save_screenshot("00.login.png")
return driver
참고내용
https://suucong.tistory.com/58#google_vignette
'🤖정보보안 > 💠1분지식' 카테고리의 다른 글
[Auth.js] [auth][error] AccessDenied: AccessDenied. Read more at https://errors.authjs.dev#accessdenied (0) | 2024.07.02 |
---|---|
[Auth.js] 로그인 직후 useSession undefined 현상 해결 (0) | 2024.06.28 |
[정보] 메일서버 쉽게설치하기 docker mailserver (0) | 2024.06.17 |
[Auth.js] Error: NEXT_REDIRECT 해결방법 (0) | 2024.06.17 |
[AI] Meta Llama 3 적용 후기 (0) | 2024.06.16 |