作者rexyeah (ccccccc)
看板Python
标题Re: [问题] 请教如何背景执行?
时间Thu Feb 21 11:50:53 2019
from selenium.webdriver.chrome.options import Options
opts = Options()
opts.add_argument('--headless')
opts.add_argument('--disable-gpu')
self.driver = webdriver.Chrome(driver, chrome_options=opts)
※ 引述《Sagbtoautumn (小馒头)》之铭言:
: 各位前辈大家好,小弟前一阵子也自己练习网页爬虫...
: 但遇到一个问题想请教各位前辈.
: 网路上很多教学会开一个web browser,然後再针对网页物件作操作.
: (例如开启网页,然後寻找网页中某个按键的name,然後再对其做相关操作.)
: EXECurPath = os.path.dirname(os.path.abspath( _file_ ))
: Chrome_Path = EXECurPath + "\geckodriver\chromedriver.exe"
: browser = webdriver.Chrome(Chrome_Path)
: browser.get("https://www.google.com.tw/")
: ...爬虫code省略...
: 但这都是会开启web browser.因为某些需求,是否能不开启web browser视窗.
: 依然可以达到爬虫效果呢?
: 请问有办法背景执行而不弹出cmd视窗吗?
: 因为当弹出web browser时候影响其他在执行的工作.
: (当然有人会给建议,将视窗长与宽设定很小或是产生cmd视窗在边缘...
: 但目前可能不朝这两个方向)
: 希望各位前辈或高手能给小弟我一个方向,在此先说声感谢您了.
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.221.35.72
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1550721056.A.8FE.html