selenium爬取图片
一.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/zCt1hO7Eb4RaBw9xs0MRwubuMyNoW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wGk1ieKeMAR6cAHzUMtP8RsTv78sxB1u+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/zCt1hO7Eb4RaBw9xs0MRwubuMyNoW9L6lzJkz7zHm2tEWIRQOveJHTZKxoS2UuhbPA0eRVJfUVOVI1Njya2lUxK4NLQTZKBwVU513qn4wp5HWS92NGY3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8q3yG3UKzq/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爬取图片的更多相关文章
- [python爬虫] 爬取图片无法打开或已损坏的简单探讨
本文主要针对python使用urlretrieve或urlopen下载百度.搜狗.googto(谷歌镜像)等图片时,出现"无法打开图片或已损坏"的问题,作者对它进行简单的探讨.同时 ...
- AotucCrawler 快速爬取图片
AotucCrawler 快速爬取图片 今天介绍一款自动化爬取图片项目. GitHub: https://github.com/YoongiKim/AutoCrawler Google, Naver ...
- [Python爬虫] Selenium爬取新浪微博客户端用户信息、热点话题及评论 (上)
转载自:http://blog.csdn.net/eastmount/article/details/51231852 一. 文章介绍 源码下载地址:http://download.csdn.net/ ...
- Java jsoup爬取图片
jsoup爬取百度瀑布流图片 是的,Java也可以做网络爬虫,不仅可以爬静态网页的图片,也可以爬动态网页的图片,比如采用Ajax技术进行异步加载的百度瀑布流. 以前有写过用Java进行百度图片的抓取, ...
- selenium爬取煎蛋网
selenium爬取煎蛋网 直接上代码 from selenium import webdriver from selenium.webdriver.support.ui import WebDriv ...
- 利用selenium爬取京东商品信息存放到mongodb
利用selenium爬取京东商城的商品信息思路: 1.首先进入京东的搜索页面,分析搜索页面信息可以得到路由结构 2.根据页面信息可以看到京东在搜索页面使用了懒加载,所以为了解决这个问题,使用递归.等待 ...
- 利用Selenium爬取淘宝商品信息
一. Selenium和PhantomJS介绍 Selenium是一个用于Web应用程序测试的工具,Selenium直接运行在浏览器中,就像真正的用户在操作一样.由于这个性质,Selenium也是一 ...
- Scrapy 框架 使用 selenium 爬取动态加载内容
使用 selenium 爬取动态加载内容 开启中间件 DOWNLOADER_MIDDLEWARES = { 'wangyiPro.middlewares.WangyiproDownloaderMidd ...
- 使用selenium爬取网站动态数据
处理页面动态加载的爬取 selenium selenium是python的一个第三方库,可以实现让浏览器完成自动化的操作,比如说点击按钮拖动滚轮等 环境搭建: 安装:pip install selen ...
随机推荐
- NC20439 [SHOI2017]期末考试
NC20439 [SHOI2017]期末考试 题目 题目描述 有 \(n\) 位同学,每位同学都参加了全部的 \(m\) 门课程的期末考试,都在焦急的等待成绩的公布.第 \(i\) 位同学希望在第 \ ...
- 数学公式 Latex 练习
\[1+x+x^2+x^3+\cdots=\frac{1}{1-x}\quad x\in(-1, 1) \] 证明:设左边式子项数为 \(n\) 那么可以得到: \[\begin{split} S & ...
- 各大厂的语音识别Speech To Text API使用体验
最近发现有声读物能极大促进我的睡眠,但每个前面都有一段开场语,想把它剪掉,但是有多个开场语,所以就要用到语音识别判断一下再剪. 前两年在本地搭建过识别的环境,奈何识别准确率不行,只能找找API了,后面 ...
- Oracle oci python sdk简单使用
听说Oracle有个oracle always free计划,所以赶紧申请了个Oracle Cloud的账号,主要是用来FQ用的,之前用过Google的,不过只有1年的期限,由此看来这个很吸引人,搭建 ...
- 2022年windows的Visual Studio 安装后初始配置
目录 前言 1.开发环境设置,修改存储空间 打开编译器,选择工具-->导入和导出设置-->重置所有设置-->下一步 修改盘符-->下一步->选择环境->完成 2.主 ...
- AtCoder Beginner Contest 261 F // 树状数组
题目链接:F - Sorting Color Balls (atcoder.jp) 题意: 有n个球,球有颜色和数字.对相邻的两球进行交换时,若颜色不同,需要花费1的代价.求将球排成数字不降的顺序,所 ...
- Object类中wait代餐方法和notifyAll方法和线程间通信
Object类中wait代餐方法和notifyAll方法 package com.yang.Test.ThreadStudy; import lombok.SneakyThrows; /** * 进入 ...
- .netcore 定制化项目开发的思考和实现
今年年初进了一家新公司,进入之后一边维护老项目一边了解项目流程,为了接下来的项目重做积累点经验. 先说下老项目吧,.net fx 3.5+oracle...... 在实际维护中逐渐发现,老项目有标准版 ...
- 最近公共祖先(LCA)学习笔记 | P3379 【模板】最近公共祖先(LCA)题解
研究了LCA,写篇笔记记录一下. 讲解使用例题 P3379 [模板]最近公共祖先(LCA). 什么是LCA 最近公共祖先简称 LCA(Lowest Common Ancestor).两个节点的最近公共 ...
- 在Ubuntu下编译安装GreatSQL
在Ubuntu下编译安装GreatSQL 本次介绍如何利用Docker构建Ubuntu环境,并将GreatSQL源码编译成二进制文件. 1.准备工作 先创建本次Docker的workdir为 /dat ...