Ubuntu Chrome+ChromeDriver와 Python Selenium 연동

2021. 4. 19. 21:13서버 프로그래밍

웹페이지 크롤링시에 동적으로 HTML이 렌더링을 하는 사이트들은 전통적인 간단한 방법으로는 최종 HTML을 가져올수가 없다. 따라서, Chrome과 같은 웹브라우저를 이용하여 해당 페이지의 렌더링을 한 다음, 최종 렌더링된 HTML을 가져오는 방법이 필요하다. 

1. Ubuntu에 Chrome 설치

2. Ubuntu에 ChromeDriver 설치

3. Python에 Selnium 설치

4. Selenium을 이용하여 ChromeDriver를 호출하여 Chrome 실행 및 결과값 가져오기

 

<주의> uWSIG로 실행시에는 admin 계정으로 실행이 되는 것이 아니므로 다음 2가지 사항에 대한 조치가 필요함

- chrome driver의 옵션에서 log 폴더 경로 등은 접근 가능한 곳으로 지정

- chrome과 chrome driver의 실행 경로를 config 파일에 지정

The missing commands in question are usually present in /bin or /usr/bin, adding these to the path variable will likely solve your problem

Environment="PATH=/home/gbadmin/myproject/myprojectenv/bin:/usr/bin:/bin"

stackoverflow.com/questions/45906997/uwsgi-python-subprocess-chrome-firefox-failed

 

uWSGI python subprocess chrome/firefox failed

I have a python flask app under uWSGI served using nginx. The python code calls subprocess.Popen() to run a browser (i.e. Firefox, Chrome) but the uWSGI log shows errors. The error is related to li...

stackoverflow.com

 

Ubuntu에 Chrome 설치 방법

webnautes.tistory.com/1184

 

Ubuntu 20.04 / 18.04에 Chrome 웹 브라우저 64bit 설치하기

Ubuntu 20.04 / 18.04에 크롬 웹 브라우저를 설치하는 방법을 설명합니다. 2018. 5. 20 최초 작성 2020. 7. 11 Ubuntu 20.04에서 동작 확인 크롬 웹 브라우저 패키지를 설치하기 위해 필요한 인증키를 등록합니

webnautes.tistory.com

Chrome Web Driver와 Selenium 설치 및 사용 방법

linuxhint.com/chrome_selenium_headless_running/

 

Running Selenium Headless with Chrome – Linux Hint

If you want to do Selenium web automation or web scrapping with Chrome web browser, it runs the graphical version of the Chrome web browser by default. It is not a problem when you’re running your Selenium script from a Linux graphical desktop environmen

linuxhint.com

Selenium 공식 레퍼런스

selenium-python.readthedocs.io/

 

Selenium with Python — Selenium Python Bindings 2 documentation

Note This is not an official documentation. If you would like to contribute to this documentation, you can fork this project in GitHub and send pull requests. You can also send your feedback to my email: baiju.m.mail AT gmail DOT com. So far 50+ community

selenium-python.readthedocs.io

 

역시 오래된 레퍼런스는 불필요한 시간 낭비를 초래한다.

blog.testproject.io/2018/02/20/chrome-headless-selenium-python-linux-servers/

 

Running Chrome Headless with Selenium & Python on Linux Servers | TestProject

How to run UI Automation Tests on remote Linux servers with Chrome headless Tutorial. Using CentOS as Linux server but achieved on most Linux environments

blog.testproject.io

medium.com/@hoppy/how-to-test-or-scrape-javascript-rendered-websites-with-python-selenium-a-beginner-step-by-c137892216aa

 

How to Scrape Javascript Rendered Websites with Python & Selenium

In this guide:

medium.com

www.tutorialspoint.com/python_web_scraping/python_web_scraping_dynamic_websites.htm

 

Python Web Scraping - Dynamic Websites - Tutorialspoint

Python Web Scraping - Dynamic Websites In this chapter, let us learn how to perform web scraping on dynamic websites and the concepts involved in detail. Introduction Web scraping is a complex task and the complexity multiplies if the website is dynamic. A

www.tutorialspoint.com

stackoverflow.com/questions/62440799/cant-run-selenium-on-ubuntu-with-python

 

Cant run Selenium on Ubuntu with Python

I cant run or install selenium on Ubuntu 18.04.3 ... I followed this tutorial: https://medium.com/@hoppy/how-to-test-or-scrape-javascript-rendered-websites-with-python-selenium-a-beginner-step-by-

stackoverflow.com

github.com/ponty/pyvirtualdisplay/tree/2.1

 

ponty/PyVirtualDisplay

Python wrapper for Xvfb, Xephyr and Xvnc. Contribute to ponty/PyVirtualDisplay development by creating an account on GitHub.

github.com

www.pythonanywhere.com/forums/topic/27144/

 

Python Selenium TypeError: init() got an unexpected keyword argument 'options : Forums : PythonAnywhere

You cannot use a different version at all with Firefox. That's the latest version of selenium that works with the version of Firefox that will run on PythonAnywhere. If you want to use Chrome, we can update you to our new, experimental virtualization syste

www.pythonanywhere.com