一.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. NC15979 小q的数列

    NC15979 小q的数列 题目 题目描述 小q最近迷上了各种好玩的数列,这天,他发现了一个有趣的数列,其递推公式如下: \[f[i] = \left\{ \begin{array}{l} 0 ,&a ...

  2. 《Ranked List Loss for Deep Metric Learning》CVPR 2019

    Motivation: 深度度量学习的目标是学习一个嵌入空间来从数据点中捕捉语义信息.现有的成对或者三元组方法随着模型迭代过程会出现大量的平凡组导致收敛缓慢.针对这个问题,一些基于排序结构的损失取得了 ...

  3. Java开发学习(九)----IOC之核心容器

    这里所说的核心容器,大家可以把它简单的理解为ApplicationContext,前面虽然已经用到过,但是并没有系统的介绍过,接下来咱们从以下几个问题入手来下容器的相关知识: 如何创建容器? 创建好容 ...

  4. pyinstaller打包一些三方库后,报资源不存在

    在目录site-packages\PyInstaller\hooks下新建对应文件hook-对应三方库名字.py,如hook-ngender.py 编辑hook-ngender.py: from Py ...

  5. day05 Java_循环_基本类型数组

    精华笔记: 循环结构: for结构:应用率高.与次数相关的循环 三种循环结构的选择规则: 先看循环是否与次数相关: 若相关----------------------------直接上for 若无关, ...

  6. JavaScript进阶内容——BOM详解

    JavaScript进阶内容--BOM详解 在上一篇文章中我们学习了DOM,接下来让我们先通过和DOM的对比来简单了解一下BOM 首先我们先来复习一下DOM: 文档对象模型 DOM把文档当作一个对象来 ...

  7. 第七天python3 函数、参数及参数解构(二)

    函数参数 参数规则: 参数列表参数一般顺序是:普通参数<--缺省参数<--可变位置参数<--keyword-only参数(可带缺省值)<--可变关键字参数 def fn(x,y ...

  8. 2022-7-18 第五组 pan 面向对象

    面向过程 向过程就是:面向过程,其实就是面向着具体的每一个步骤和过程,把每一个步骤和过程完成,然后由这些功能方法相互调用,完成需求. 面向对象 什么是面向对象: 面向对象思想就是不断的创建对象,使用对 ...

  9. Clickhouse 实现 MaterializedPostgreSQL

    Clickhouse 实现 MaterializedPostgreSQL 开发环境:macOS 12.4 + docker 一.环境搭建 docker-compose.yml services: po ...

  10. python获取线程返回值

    python获取线程返回值 前言 工作中的需求 将前端传过来的字符串信息通过算法转换成语音,并将语音文件返回回去 由于算法不是我写的,只需要调用即可,但是算法执行速度相当缓慢 我的优化思路是,将前端的 ...