selenium-禁止图片加载

#!encoding=utf-8
from lxml import etree
from selenium import webdriver

from selenium.webdriver.chrome.options import Options

options = Options()
No_Image_loading = {"profile.managed_default_content_settings.images": 2}
options.add_experimental_option("prefs", No_Image_loading)

browser = webdriver.Chrome(options=options)
browser.get("http://www.taobao.com")
content = browser.page_source

html = etree.HTML(content)
title = html.xpath('//div[@class="ui blue segment"]/div[2]/text()')
print(title)

  

上一篇:selenium模块无头化浏览器 设置不加载页面css、图片、js


下一篇:Selenium+java设置元素等待