selenium容易忽视的知识点
生活随笔
收集整理的這篇文章主要介紹了
selenium容易忽视的知识点
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
關(guān)閉圖片加載
from selenium import webdriveroptions = webdriver.ChromeOptions() options.add_experimental_option('prefs', {'profile.managed_default_content_settings.images': 2}) browser = webdriver.Chrome(options=options) browser.get('https://www.jd.com')處理下拉
# 將滾動條拉到最下面的位置,因?yàn)橥吕拍軐⑦@一頁的商品信息全部加載出來 browser.execute_script('document.documentElement.scrollTop=10000') # 隨機(jī)延遲,等下元素全部刷新 time.sleep(random.randint(1, 3)) browser.execute_script('document.documentElement.scrollTop=0')輸入enter
from selenium.webdriver.common.keys import Keys browser.find_element_by_id('key').send_keys(Keys.ENTER)總結(jié)
以上是生活随笔為你收集整理的selenium容易忽视的知识点的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 白灰墙面如何挂横幅
- 下一篇: tornado设置cookie和sees