from urllib import request
from selenium import webdriver
import time
driver = webdriver.Chrome()
url = 'http://i.jandan.net/ooxx'
driver.get(url)
# a = []
for i in range(8):
hrefs = driver.find_elements_by_xpath('//*[@id]/div[1]/p/a')
for i in hrefs:
href = i.get_attribute('href')
name = href.split('/')[-1]
# a.append(href)
request.urlretrieve(href,name)
js = 'window.scrollBy(0,14200)'
driver.execute_script(js)
time.sleep(.05)
next_page = driver.find_element_by_partial_link_text('下一页')
next_page.click()
# print(len(a))
time.sleep(.1)
网友评论