python爬虫抓取橘梨纱照片
来源:互联网 发布:多媒体教学软件下载 编辑:程序博客网 时间:2024/04/27 17:23
目的:通过模拟web请求,抓取web页面,筛选出我们想要的数据。
一.获取完整页面代码并输出
使用python的urllib库来完成
import urllib
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
html = getHtml("http://www.baidu.com")
print html
运行结果
二.筛选图片
抓取网站为:
http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1478187608516_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=橘梨纱
的图片
查看网页源码 发现图片格式为这样
编写如下代码
import re
import urllib
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'"objURL":"(.*?)"'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
return imglist
html=getHtml("http://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1478187608516_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=橘梨纱")
print getImg(html)
成功输出结果
先完成输出url啦 后面再下载图片保存到本地。
- python爬虫抓取橘梨纱照片
- 利用Python爬虫,抓取淘宝MM照片
- Python爬虫实战 抓取淘宝照片
- python 爬虫抓取淘宝MM照片
- Python爬虫实战:抓取淘宝MM照片
- Python爬虫实战:抓取淘宝MM照片
- Python爬虫实战四之抓取淘宝MM照片
- Python爬虫:动态网页抓取淘宝“淘女郎”照片
- Python爬虫实战(4):抓取淘宝MM照片
- Python爬虫实战(4):抓取淘宝MM照片
- 一次Python爬虫的修改,抓取淘宝MM照片
- Python爬虫抓取马蜂窝游记的照片 基于xpath
- Python爬虫实战之抓取淘宝MM照片(一)
- Python爬虫实战之抓取淘宝MM照片(二)
- Python爬虫实战之抓取淘宝MM照片(三)
- Python爬虫实战之抓取淘宝MM照片(四)
- Python爬虫百度照片
- python爬虫学习笔记3—— 抓取淘宝MM照片
- PAT-BL-1011
- uIP无操作系统(裸机)移植
- 树莓派3创建ftp服务
- PHP 函数
- python数据结构学习笔记-2016-11-05-01-队列ADT及其实现
- python爬虫抓取橘梨纱照片
- MySQL,-----------17
- KALI中如何启用VNC
- throw_try_catch
- 编程规范
- Floyd最短路算法
- 如何让别人在搜索引擎找到自己的博客
- AdaBoost算法原理及OpenCV实例
- leetcode_160. Intersection of Two Linked Lists 找两个单链表的交集的起始位置