# coding=utf-8
from lxml import etree
from selenium import webdriver
from
selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import ActionChains
import time
driver = webdriver.Chrome()
driver.get('
https://www.manhuatai.com/fengqicanglan/115hs.html')
menu = driver.find_element_by_css_selector(".mh_nextpage")
actions = ActionChains(driver)
for i in range(3):
# 智能等待
try:
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((
By.ID, "comiclist")))
except NoSuchElementException:
print('找不到元素异常')
# 获取图片链接
res = driver.page_source
html = etree.HTML(res)
pictrue_url = html.xpath('//div[@class="mh_comicpic"]/img/@src')[0]
print(pictrue_url)
# 在“下一页”位置点击鼠标左键
actions.click(menu)
actions.perform()
driver.close()
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/531967
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.