qdyxmas's Room

Done is better than perfect...

linux下后台运行selenium

linux下后台运行selenium:

安装浏览器:

Google Chrome 77.0.3865.75configure
ChromeDriver 77.0.3865.40

pyautogui:

安装Xvfb后启动虚拟显示器
Xvfb -ac :0 -screen 0 1920x1080x24
export DISPLAY=:0

FAQ:

Q:    NOTE: You must install tkinter on Linux to use MouseInfo. Run the following: sudo apt-get install python3-tk python3-dev
A:    python3.6安装tk/tcl:
      1.下载tcl包和tk包 https://www.tcl.tk/software/tcltk/download.html
      2.安装包https://blog.csdn.net/and_december/article/details/71178539

运行脚本

# coding:utf-8 
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--remote-debugging-port=9222')
browser = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.baidu.com")

标签 

1 评论

  1. CharlesVex
    /回复

    “I haven’t seen you in these parts,” the barkeep said, sidling over and above to where I sat. “Repute’s Bao.” He stated it exuberantly, as if solemn word of honour of his exploits were shared by means of settlers hither multitudinous a ‚lan in Aeternum. He waved to a expressionless keg apart from us, and I returned his gesture with a nod. He filled a field-glasses and slid it to me across the stained red wood of the court prior to continuing. “As a betting chains, I’d be willing to wager a fair bit of silver you’re in Ebonscale Reach for more than the wet one's whistle and sights,” he said, eyes glancing from the sword sheathed on my hip to the capitulate slung across my back. http://images.google.li/url?q=https://renewworld.ru/data-vyhoda-new-world/

评论