Python爬虫-selenium模拟豆瓣电影鼠标下拉

selenium用 JS模拟豆瓣电影鼠标下拉

----------------------------------------------

 

 1 '''
 2 任务:
 3 1. 利用selenium模拟鼠标下拉
 4 2. 每次多出现几部电影的信息
 5 '''
 6 
 7 from selenium import webdriver
 8 import time
 9 
10 url = 'https://movie.douban.com/typerank?type_name=%E5%89%A7%E6%83%85&type=11&interval_id=100:90&action='
11 
12 driver = webdriver.Chrome()
13 driver.get(url)
14 
15 
16 # 向下滚动10000像素
17 js = 'document.body.scrollTop=10000'
18 time.sleep(3)
19 
20 
21 driver.save_screenshot('douban1.png')
22 
23 driver.execute_script(js)
24 time.sleep(3)
25 
26 
27 driver.save_screenshot('douban2.png')

 

=====================================================

# 向下滚动10000像素
 js = 'document.body.scrollTop=10000'

# selenium用driver.execute_script(js)执行JS语句
driver.execute_script(js)

 

转载于:https://www.cnblogs.com/xuxaut-558/p/10088694.html

你可能感兴趣的:(Python爬虫-selenium模拟豆瓣电影鼠标下拉)