python下爬某个网页的图片】的更多相关文章

#coding=utf-8 import re import urllib def getHtml(url): #获取url对应得源码 page = urllib.urlopen(url) html = page.read() return html def getImg(html): #获取 reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = re.findall(imgre,html) x = 0…
import urllib.request,os import re # 获取html 中的内容 def getHtml(url): page=urllib.request.urlopen(url) html=page.read() return html path='本地存储位置' # 保存路径 def saveFile(x): if not os.path.isdir(path): os.makedirs(path) t = os.path.join(path,'%s.jpg'%x) ret…
#-*-coding:utf-8-*- import os import uuid import urllib2 import cookielib '''获取文件后缀名''' def get_file_extension(file): return os.path.splitext(file)[1] '''創建文件目录,并返回该目录''' def mkdir(path): # 去除左右两边的空格 path=path.strip() # 去除尾部 \符号 path=path.rstrip("\\&…
本人比较喜欢海贼王漫画,所以特意选择了网站http://www.mmonly.cc/ktmh/hzw/list_34_2.html来抓取海贼王的图片. 因为是刚刚学习python,代码写的不好,不要喷. 功能主要抓取此网页的图片如下: 贴代码: #!/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import re url1 = "http://www.mmonly.cc/ktmh/hzw/list_34_2.html&quo…
  python连续爬取多个网页的图片分别保存到不同的文件夹 作者:vpoet mail:vpoet_sir@163.com #coding:utf-8 import urllib import urllib2 import re # 将正则表达式编译成Pattern对象 rex=r'src="(http://imgsrc.baidu.com/forum/w%3D580.*?\.jpg)"'; pages = ('); for page in pages: pageurl = &quo…
python爬取某个网页的图片-如百度贴吧 作者:vpoet mail:vpoet_sir@163.com 注:随意copy,不用告诉我 #coding:utf-8 import urllib import urllib2 import re if __name__ =="__main__": rex=r'src="(http://imgsrc.baidu.com/forum/w%3D580.*?\.jpg)"'; Response=urllib2.urlopen(…
CSS实现网页背景图片自适应全屏 功能:实现能自适应屏幕大小又不会变形的背景大图,而且背景图片不会随着滚动条滚动而滚动. 以下是用CSS实现的方法: <html> <head> <meta charset="UTF-8"> <title>title</title> <style> *{ margin: 0; padding: 0; } .backend{ position: relative; top: 0 ; l…
import urllib.request import re #py抓取页面图片并保存到本地 #获取页面信息 def getHtml(url): html = urllib.request.urlopen(url).read() return html #通过正则获取图片 def getImg(html): reg = 'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) imglist = re.findall(imgre,html)…
刚开学时有一段时间周末没事,于是经常在P站的特辑里收图,但是P站加载图片的速度比较感人,觉得自己身为计算机专业,怎么可以做一张张图慢慢下这么low的事,而且这样效率的确也太低了,于是就想写个程序来帮我下,但是只会C与c++的我看来是无法用他们来做这事的,于是就去学了下简单,强大的python,不得不说,python的模块的确叼,依靠几个模块就可以在完全不知道原理的前提下让程序执行相应功能,这样虽然爽但对于学习不利,我这次就权当写着玩吧,在我学会怎样使用c++来做这事之前我不会再使用python编…
转载:python 爬虫抓取心得分享 title:python 爬虫抓取心得分享 0x1.urllib.quote('要编码的字符串')如果你要在url请求里面放入中文,对相应的中文进行编码的话,可以用:urllib.quote('要编码的字符串') query = urllib.quote(singername) url = 'http://music.baidu.com/search?key='+query response = urllib.urlopen(url) text = resp…