Author Topic: Python Chrome script  (Read 45 times)

0 Members and 1 Guest are viewing this topic.

Offline afrocuban

  • Moderator
  • *****
  • Posts: 546
    • View Profile
Python Chrome script
« on: December 30, 2024, 03:44:34 pm »
This is fork and upgrade of Ivek's selenium script found here:

Quote
http://www.videodb.info/forum_en/index.php/topic,4362.msg22691.html#msg22691


For this to work ensure that:


Quote
A. You installed python
B. You installed selenium by


Quote
pip install selenium

C. You have your Chrome bin on a PATH
D. You have Python folder on your PATH
E. pythonw.exe is not missing, or it's containing folder is on the PATH


This script:


Quote
1. Uses Chrome browser instead Firefox
2. Uses chromedriver.exe instead geckodriver
3. Starts chromedriver.exe silently
4. Silently invokes browser in a headless mode (no pop-up windows of browser)
5. Scrapes .htm page of a given url
6. No path is needed to set manually inside the script - it is set to be relative to the path of selenium script!

For using relative path, ensure:

Quote
6A. You put this script into "Scripts" folder of your PVD instance.
6B. You put appropirate chromedriver.exe to the "Script" folder, too.

To silently invoke selenium script itself by PVD's .psf script (no pop-up windows of selenium script's cmd window), be sure to use pythonw.exe instead of python.exe, like this for example:

Quote
FileExecute('pythonw.exe', '"' + ScriptPath + 'selenium_script-Chrome.py" "' + URL + '" "' + ScriptPath + BASE_DOWNLOAD_FILE_NO_BOM + '"');

Now, the last one will probably be ensured by those who maintain corresponding scripts if interested in, and for now, those are Ivek and me, but be sure to check if it's there anyway.

From this point on, everything is automated and headless.
« Last Edit: December 30, 2024, 03:53:09 pm by afrocuban »

 

anything