目录
一、安装chrome
2383 2024-08-02 18:52:47 apt -y update
2384 2024-08-02 18:53:14 apt -y install google-chrome-stable
2385 2024-08-02 18:53:50 sudo google-chrome --version
这里实际安装完之后是当时的chrome-stable,也就是127.0.6533.88
二、安装ChromeDriver驱动
2314 2024-08-02 15:39:41 wget https://chromedriver.storage.googleapis.com/100.0.4896.20/chromedriver_linux64.zip
2327 2024-08-02 15:50:31 unzip chromedriver_linux64.zip
2328 2024-08-02 15:50:34 ls -al
2329 2024-08-02 15:50:53 cp /usr/bin
2330 2024-08-02 15:51:01 cp chromedriver /usr/bin
这里安装之后实际上ChromeDriver驱动是100.0.4896.20
三、运行应用和错误分析
(links) root@prod-0003:~/service# sudo google-chrome --version
Google Chrome 127.0.6533.88
(links) root@prod-0003:~/service# which python
(links) root@prod-0003:~/service# sudo /root/anaconda3/envs/links/bin/python schedule_main.py
2024-08-05 14:22:28.037 | INFO | main:<module>:62 - ======= main startup ========
2024-08-05 14:22:28.140 | INFO | main:do_only_test:22 - test task per 60s at:('do_only_test', datetime.datetime(2024, 8, 5, 14, 22, 28, 139998))
2024-08-05 14:22:28.140 | INFO | main:do_all:28 - ======= start do_genetica2019_sld_cu ========
2024-08-05 14:22:28.704 | ERROR | service.genetica2019_sld_cu_service:execute_item:70 - execute_item username:gbwhatsappdownload password:Aa123456Aa have exception:Message: session not created: This version of ChromeDriver only supports Chrome version 100
Current browser version is 127.0.6533.88 with binary path /usr/bin/google-chrome
Stacktrace:
#0 0x5645670e3013 <unknown>
#1 0x564566e45a08 <unknown>
#2 0x564566e6ca25 <unknown>
#3 0x564566e68198 <unknown>
#4 0x564566e6456a <unknown>
#5 0x564566e9f5fa <unknown>
#6 0x564566e99823 <unknown>
#7 0x564566e6f08a <unknown>
#8 0x564566e701e5 <unknown>
#9 0x564567110e5d <unknown>
#10 0x56456712a061 <unknown>
#11 0x564567112bb5 <unknown>
#12 0x56456712ae08 <unknown>
#13 0x5645671062f0 <unknown>
#14 0x564567146988 <unknown>
#15 0x564567146b08 <unknown>
#16 0x5645671605dd <unknown>
#17 0x7fab50229609 <unknown>
根据报错提示,发现是版本不一致,根据对应关系 Chrome for Testing availability ,重新下载正确的驱动版本即可。
(links) root@prod-0003:~/service# wget https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.88/linux64/chromedriver-linux64.zip
--2024-08-05 14:28:51-- https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.88/linux64/chromedriver-linux64.zip
Resolving storage.googleapis.com (storage.googleapis.com)... 74.125.200.207, 142.250.4.207, 142.251.12.207, ...
Connecting to storage.googleapis.com (storage.googleapis.com)|74.125.200.207|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9330660 (8.9M) [application/zip]
Saving to: 'chromedriver-linux64.zip'
chromedriver-linux64.zip 100%[=================================================================>] 8.90M --.-KB/s in 0.04s
2024-08-05 14:28:51 (242 MB/s) - 'chromedriver-linux64.zip' saved [9330660/9330660]
(external_links) root@prod-0003:~/service# unzip chromedriver-linux64.zip
Archive: chromedriver-linux64.zip
inflating: chromedriver-linux64/LICENSE.chromedriver
inflating: chromedriver-linux64/THIRD_PARTY_NOTICES.chromedriver
inflating: chromedriver-linux64/chromedriver
(links) root@ptc-tsla-prod-0003:~/service/chromedriver-linux64# cp chromedriver /usr/bin