37,719
社区成员
发帖
与我相关
我的任务
分享
#!C:\Python27
#coding=utf-8
import urllib
import re
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = 'src="([^ >]+\.(?:jpeg|jpg))"'
imgre = re.compile(reg)
print imgre
imglist = re.findall(imgre,html)
for imgurl in imglist:
urllib.urlretrieve(imgurl)
print imgurl
html = getHtml("https://www.qqbody.com/gxtouxiang/19290.html")
print '*******************************************************************************'
getImg(html)
#!C:\Python27
#coding=utf-8
import urllib
import re
import os.path
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = 'src="([^ >]+\.(?:jpeg|jpg))"'
imgre = re.compile(reg)
print imgre
imglist = re.findall(imgre,html)
for imgurl in imglist:
fil_name = os.path.split(imgurl)[-1]
file_data = urllib.urlretrieve(imgurl,fil_name)
print imgurl
html = getHtml("https://www.qqbody.com/gxtouxiang/19290.html")
print '*******************************************************************************'
getImg(html)
#coding=utf-8
import urllib.request
import re
def getHtml(url):
page = urllib.request.urlopen(url)
html = page.read().decode('gb2312')
return html
def getImg(html):
reg = 'src="([^ >]+\.(?:jpeg|jpg))"'
imgre = re.compile(reg)
print(imgre)
imglist = re.findall(imgre,html)
for imgurl in imglist:
urllib.request.urlretrieve(imgurl)
print(imgurl)
html = getHtml("https://www.qqbody.com/gxtouxiang/19290.html")
print('*******************************************************************************')
getImg(html)