一.https/http开头的图片

1.我们以百度为例,下载百度图片到本地。

2.定位到该元素的img标签

from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://www.baidu.com") # 进入百度首页
driver.implicitly_wait(10) # 设置全局隐性等待
element = driver.find_element(by=By.XPATH, value="//img[@id='s_lg_img']") # 定位元素

3.获取图片的地址

url = element.get_attribute("src")  # 获取图片链接

3.将图片以二进制保持到本地

with open("./img/baidu.png", mode="wb")as f:
f.write(requests.get(url).content) # 将图片以二进制写入

4.全部代码

from selenium import webdriver
from selenium.webdriver.common.by import By
import requests driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.implicitly_wait(10)
element = driver.find_element(by=By.XPATH, value="//img[@id='s_lg_img']")
url = element.get_attribute("src") # 获取图片链接 with open("./img/baidu.png", mode="wb")as f:
f.write(requests.get(url).content) # 将图片以二进制写入 driver.quit() 

二.base64加密的图片

1.base64加密过的图片在网页上都是以data:image开头的,不能直接获取图片地址下载,需要先解码后再保存

2.我们直接浏览器上拷贝一个img的src值(base64加密过的),截取需要解码的部分,base64,往后的部分

url_path = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABMCAYAAADHl1ErAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAATKADAAQAAAABAAAATAAAAAAWucfgAAAbL0lEQVR4Ab2bW5Ndx1XH+1zmohlJI8mSovhaNjFx4sQklQovhBQPEIoqqvgEeeRbwQsfAaogVVDFAwUUISE4wQlOMLHsJJZjybqNNCPNufD/rUt373POyCbEtHR2d697r1593XtGf/oXh8vRqBT7FRWU7AnMao6LYs0qfRAlrQkS53i8LEX/Ez6CQcmeeiRchF5eLjvcqJarwiis8htlyFvFIQR8qB6IShg8fRki6jLdbEj5YxBKY8OAtfZFwTQb3rmiuJotjXmVxKFq/zCt1hO7Eb4RaBw9xs0MRwubuMyNoW9L6lzJk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eMAR6cAHzUMtP8RsTv78sxB1u+PxNuSxF45RnBdC7EWfdv6rZBzkq7TcEn9JjOLao0BOWQboBYk1xni7T8q3yG3UKzq/b3FonR/Gqv0DbkPmpsGB20rmjtySK0ULRNtDTt6A/BuaE91mLAhnTvYFwea9d+X5HFxvSTHIa9YdO5oqtXRs+bY6wV6UJZbhMUrKKgpTX1lSz3LqBs8WQcXsvOgT46pMqDujmRzpnrdLBUpLFpvnhtR1fIHKA1DDVnsXvv7e/EfCJFblTcATLMmoW1JMuz4qD6TH/Ic+a8JMs8CTfIcPrmwOSHdJUdMQnDSXv6QwXyx1oFmeD/v52FPf8DySp0Gc9oSoMAAAAASUVORK5CYII='
url = url_path[22:]

3.通过base64解码为二进制

url_b64 = base64.b64decode(url)

4.保存到本地

with open("./img/base64.png", mode="wb")as f:
f.write(url_b64)

这个需要注意的是保存的图片后缀要和原文件类型一致,png格式(data:image/png)

5.全部代码

import base64

url_path = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABMCAYAAADHl1ErAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAATKADAAQAAAABAAAATAAAAAAWucfgAAAbL0lEQVR4Ab2bW5Ndx1XH+1zmohlJI8mSovhaNjFx4sQklQovhBQPEIoqqvgEeeRbwQsfAaogVVDFAwUUISE4wQlOMLHsJJZjybqNNCPNufD/rUt373POyCbEtHR2d697r1593XtGf/oXh8vRqBT7FRWU7AnMao6LYs0qfRAlrQkS53i8LEX/Ez6CQcmeeiRchF5eLjvcqJarwiis8htlyFvFIQR8qB6IShg8fRki6jLdbEj5YxBKY8OAtfZFwTQb3rmiuJotjXmVxKFq/zCt1hO7Eb4RaBw9xs0MRwubuMyNoW9L6lzJkz7zHm2tEWIRQOveJHTZKxoS2UuhbPA0eRVJfUVOVI1Njya2lUxK4NLQTZKBwVU513qn4wp5HWS92NGY3Co4SZ0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Kzq/b3FonR/Gqv0DbkPmpsGB20rmjtySK0ULRNtDTt6A/BuaE91mLAhnTvYFwea9d+X5HFxvSTHIa9YdO5oqtXRs+bY6wV6UJZbhMUrKKgpTX1lSz3LqBs8WQcXsvOgT46pMqDujmRzpnrdLBUpLFpvnhtR1fIHKA1DDVnsXvv7e/EfCJFblTcATLMmoW1JMuz4qD6TH/Ic+a8JMs8CTfIcPrmwOSHdJUdMQnDSXv6QwXyx1oFmeD/v52FPf8DySp0Gc9oSoMAAAAASUVORK5CYII='
url = url_path[22:]
url_b64 = base64.b64decode(url)
with open("./img/base64.png", mode="wb")as f:
f.write(url_b64)

三.镶嵌在css background-image中的图片

1.我们以获取豆瓣登录页面滑块背景图为例,先看下背景图格式。

2.先跳转到背景图片的页面

from selenium import webdriver
from selenium.webdriver.common.by import By driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.get("https://www.douban.com/")
iframe = driver.find_element(by=By.XPATH, value="//body/div[@id='anony-reg-new']/div[1]/div[1]/iframe[1]")
driver.switch_to.frame(iframe)
driver.find_element(by=By.XPATH, value="//*[contains(text(),'密码登录')]").click()
driver.find_element(by=By.ID, value="username").send_keys("13633989873")
driver.find_element(by=By.ID, value="password").send_keys("13633989873")
driver.find_element(by=By.XPATH, value="/html/body/div[1]/div[2]/div[1]/div[5]/a").click()

driver.switch_to.frame("tcaptcha_iframe_dy")
time.sleep(3)

3.编写脚本获取背景图地址

方法一:css = 'return document.getElementById("slideBg").style.backgroundImage'

方法二:js = 'return document.getElementById("slideBg").style.backgroundImage'

我们打印出来可以发现,方法一会把域名一起获取了,所以个人推荐使用方法一,不用后续去拼接了

4.截取url地址并以二进制写入

url_path = css_01[5:-2]
with open("./img/tu.png", mode="wb")as f:
f.write(requests.get(url_path).content)

5.全部代码

import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By driver = webdriver.Chrome()
driver.implicitly_wait(10)
driver.get("https://www.douban.com/")
iframe = driver.find_element(by=By.XPATH, value="//body/div[@id='anony-reg-new']/div[1]/div[1]/iframe[1]")
driver.switch_to.frame(iframe)
driver.find_element(by=By.XPATH, value="//*[contains(text(),'密码登录')]").click()
driver.find_element(by=By.ID, value="username").send_keys("13633989873")
driver.find_element(by=By.ID, value="password").send_keys("13633989873")
driver.find_element(by=By.XPATH, value="/html/body/div[1]/div[2]/div[1]/div[5]/a").click()
driver.switch_to.frame("tcaptcha_iframe_dy")
time.sleep(3)
css = "return $('[id=slideBg]').css('background-image')"
# js = 'return document.getElementById("slideBg").style.backgroundImage'
css_01 = driver.execute_script(css)
# js_01 = driver.execute_script(js)
url_path = css_01[5:-2]
with open("./img/dou.png", mode="wb")as f:
f.write(requests.get(url_path).content)
driver.quit()

需要注意的是在执行js前需要等待几秒钟,防止报:“is not defined”,要等到页面加载完成后再去执行js

selenium爬取图片的更多相关文章

  1. [python爬虫] 爬取图片无法打开或已损坏的简单探讨

    本文主要针对python使用urlretrieve或urlopen下载百度.搜狗.googto(谷歌镜像)等图片时,出现"无法打开图片或已损坏"的问题,作者对它进行简单的探讨.同时 ...

  2. AotucCrawler 快速爬取图片

    AotucCrawler 快速爬取图片 今天介绍一款自动化爬取图片项目. GitHub: https://github.com/YoongiKim/AutoCrawler Google, Naver ...

  3. [Python爬虫] Selenium爬取新浪微博客户端用户信息、热点话题及评论 (上)

    转载自:http://blog.csdn.net/eastmount/article/details/51231852 一. 文章介绍 源码下载地址:http://download.csdn.net/ ...

  4. Java jsoup爬取图片

    jsoup爬取百度瀑布流图片 是的,Java也可以做网络爬虫,不仅可以爬静态网页的图片,也可以爬动态网页的图片,比如采用Ajax技术进行异步加载的百度瀑布流. 以前有写过用Java进行百度图片的抓取, ...

  5. selenium爬取煎蛋网

    selenium爬取煎蛋网 直接上代码 from selenium import webdriver from selenium.webdriver.support.ui import WebDriv ...

  6. 利用selenium爬取京东商品信息存放到mongodb

    利用selenium爬取京东商城的商品信息思路: 1.首先进入京东的搜索页面,分析搜索页面信息可以得到路由结构 2.根据页面信息可以看到京东在搜索页面使用了懒加载,所以为了解决这个问题,使用递归.等待 ...

  7. 利用Selenium爬取淘宝商品信息

    一.  Selenium和PhantomJS介绍 Selenium是一个用于Web应用程序测试的工具,Selenium直接运行在浏览器中,就像真正的用户在操作一样.由于这个性质,Selenium也是一 ...

  8. Scrapy 框架 使用 selenium 爬取动态加载内容

    使用 selenium 爬取动态加载内容 开启中间件 DOWNLOADER_MIDDLEWARES = { 'wangyiPro.middlewares.WangyiproDownloaderMidd ...

  9. 使用selenium爬取网站动态数据

    处理页面动态加载的爬取 selenium selenium是python的一个第三方库,可以实现让浏览器完成自动化的操作,比如说点击按钮拖动滚轮等 环境搭建: 安装:pip install selen ...

随机推荐

  1. JavaScript扩展原型链浅析

    前言 上文对原型和原型链做了一些简单的概念介绍和解析,本文将浅析一些原型链的扩展. javaScript原型和原型链 http://lewyon.xyz/prototype.html 扩展原型链 使用 ...

  2. 基于脑波眼电-语音-APP控制的多功能智能轮椅

    前言:这个项目是在2016-2017完成的,做的很浅显,贴出来与大家分享,希望能有帮助. 摘要 本项目主要是针对脑电信号控制的智能轮椅的设计,脑电控制是智能医疗领域的重要研究方向,旨在帮助行动不便但智 ...

  3. Collection集合概述和集合框架介绍avi

    集合概述 在前面基础班我们已经学习过并使用过集合ArrayList<E> ,那么集合到底是什么呢?· ~集合︰集合是java中提供的一种容器,可以用来存储多个数据集合和数组既然都是容器,它 ...

  4. 【Unity学习笔记】掌握MoneBehavior中的重要属性、方法

    一.重要属性 1-1.获取自己依附的GameObject using System.Collections; using System.Collections.Generic; using Unity ...

  5. Go语言基础六:结构体和方法

    结构体 结构体是一个由用户定义的复合类型,它由一系列属性组成,每个属性都有自己的类型和值.Go语言中数组可以存储同一类型的数据,但在结构体中用户可以为不同项定义不同(或相同)的数据类型.结构体是值类型 ...

  6. Vue 配置代理

    说明:这里的vue代理是指用vue静态服务器做代理.使用的是 http-proxy-middleware 这个模块(这个模块相当于是node.js的一个插件). 版本: vue-cli 3.0以上 修 ...

  7. JavaWeb--基本概念、Web服务器与Tomcat

    前言 Java Web 其实就是一个技术的总和,把Web看成一个容器而已主要使用JavaEE技术来实现.在加上各种中间件. 整个javaWeb阶段的内容通过实际的案例贯穿学习, 所涉及到的技术知识点会 ...

  8. Nmap 操作手册 - 完整版

    目录 Nmap - 基础篇 Nmap 安装 RedHat Windows Debina & Ubuntu Others Linux Nmap 参数(简单版) 目标说明 主机发现 扫描技术 端口 ...

  9. 使用Mpvue配合Weui开发面试题题库微信小程序,并且发布到正式环境

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_116 之前的一篇文章详细阐述了微信小程序开发的准备和入门以及环境搭建,这一次我们介绍如何将微信小程序如何上线,同时配合weui美化 ...

  10. Apache DolphinScheduler 的持续集成方向实践

    今天给大家带来的分享是基于 Apache DolphinScheduler 的持续集成方向实践,分享的内容主要为以下六点: " 研发效能 DolphinScheduler CI/CD 应用案 ...