CentOS8 + Python3.6.8 + selenium + chrome +chromedriver
878
使用 centos8 为基础镜像制作的自定义镜像,内置 python 3.6.8、pip3、selenium、requests、chrome、chromedriver 及 crontabs 服务,方便调试使用 python3 + selenium + chrome + chromedriver 的脚本。
/data/
`-- example.py
docker run -dit \
-v $PWD:/data \
--name selenium \
--restart always \
chiupam/selenium:latest
docker exec -it selenium bash
python example.py
pip freeze
crontab -l # 列出定时任务
crontab -e # 修改定时任务
crontab -r # 清空定时任务
crontab <file path> # 把文件内容写入crontab定时任务蹱
# coding=utf-8
from selenium import webdriver # 必须
def main():
driver.get('https://www.baidu.com/')
print(driver.title)
driver.quit()
if __name__ == "__main__":
chrome_options = webdriver.ChromeOptions() # 必须
chrome_options.add_argument('--headless') # 必须
chrome_options.add_argument('--no-sandbox') # 必须
chrome_options.add_argument('--windows-size=1920, 1080') # 建议
driver = webdriver.Chrome(options=chrome_options) # 必须
main()
# 每天12点自动执行一次/data/example.py脚本
0 0 * * * cd /data && python3 example.py >>/data/example.log 2>&1 &
Content type
Image
Digest
Size
810.2 MB
Last updated
almost 5 years ago
docker pull chiupam/selenium