亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python爬蟲(chóng)入門(mén)教程之點(diǎn)點(diǎn)美女圖片爬蟲(chóng)代碼分享

 更新時(shí)間:2014年09月02日 11:01:43   投稿:junjie  
這篇文章主要介紹了python爬蟲(chóng)入門(mén)教程之點(diǎn)點(diǎn)美女圖片爬蟲(chóng)代碼分享,本文以采集抓取點(diǎn)點(diǎn)網(wǎng)美女圖片為例,需要的朋友可以參考下

繼續(xù)鼓搗爬蟲(chóng),今天貼出一個(gè)代碼,爬取點(diǎn)點(diǎn)網(wǎng)「美女」標(biāo)簽下的圖片,原圖。

# -*- coding: utf-8 -*- 

#--------------------------------------- 
#  程序:點(diǎn)點(diǎn)美女圖片爬蟲(chóng) 
#  版本:0.2 
#  作者:zippera 
#  日期:2013-07-26 
#  語(yǔ)言:Python 2.7 
#  說(shuō)明:能設(shè)置下載的頁(yè)數(shù) 
#--------------------------------------- 
 
import urllib2
import urllib
import re
 
 
 
pat = re.compile('<div class="feed-big-img">\n.*?imgsrc="(ht.*?)\".*?')
nexturl1 = "http://www.diandian.com/tag/%E7%BE%8E%E5%A5%B3?page="
 
 
count = 1
 
while count < 2:
 
  print "Page " + str(count) + "\n"
  myurl = nexturl1 + str(count)
  myres = urllib2.urlopen(myurl)
  mypage = myres.read()
  ucpage = mypage.decode("utf-8") #轉(zhuǎn)碼
 
  mat = pat.findall(ucpage)
  
 
  
  
  
  if len(mat):
    cnt = 1
    for item in mat:
      print "Page" + str(count) + " No." + str(cnt) + " url: " + item + "\n"
      cnt += 1
      fnp = re.compile('(\w{10}\.\w+)$')
      fnr = fnp.findall(item)
      if fnr:
        fname = fnr[0]
        urllib.urlretrieve(item, fname)
    
  else:
    print "no data"
    
  count += 1

使用方法:新建一個(gè)文件夾,把代碼保存為name.py文件,運(yùn)行python name.py就可以把圖片下載到文件夾。

相關(guān)文章

最新評(píng)論