I am learning selenium, I want to get all the image of the sample website, the image used lazyload, and the image will only be displayed when the parent element of the image appears in the visible range of the screen.
If the parent element of the image does not appear in the visible range of the screen, the following code is displayed:
<a class="picture" href="http://new.qq.com/omn/20190405/20190405A0CB58.html" target="_blank"><div class="lazyload-placeholder">终于出手规范融资业务!港证监会规定最高不得超过5倍融资</div></a>
If the parent element of the image appears in the visible range of the screen, the following code is displayed:
<a class="picture" href="http://new.qq.com/omn/20190405/20190405A0CB58.html" target="_blank"><img alt="终于出手规范融资业务!港证监会规定最高不得超过5倍融资" src="//inews.gtimg.com/newsapp_ls/0/8439863897_294195/0"></a>
I want to control the speed of scrolling to the bottom, so that the image will all be displayed.
How to control the speed of scrolling to the bottom in selenium?
I am trying to modify window.scrollTo(0, document.body.scrollHeight);
,
but it not success.
#coding:utf-8
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://new.qq.com/rolls/?ext=news")
i = 0
while (i < 10):
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(1)
i += 1