无头浏览器

from selenium  import  webdriver
from  selenium.webdriver.chrome.options  import Options
#实现无头浏览器
chrome_options=Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")



driver=webdriver.Chrome(options=chrome_options)
driver.get("http://quotes.toscrape.com/")
a=driver.find_elements_by_xpath('//span[@class="text"]')
for i in a:
    print(i.text)

 

posted @ 2020-07-30 22:59  马蹄哒哒  阅读(172)  评论(0编辑  收藏  举报