Before I saw someone else write a Python script to crawl the picture, I wrote it before with regular, recently saw BeautifulSoup so take to practice practiced hand
# -*- coding:utf8 -*-from bs4 import beautifulsoupimport os, sys,  URLLIB2,TIME,RANDOM PATH = OS.GETCWD () new_path = Os.path.join (path,u ' sexy ') If not os.path.isdir (New_path): os.mkdir (New_path) def page_loop (page=1): url = ' http://sexy.faceks.com/tag/Beauty photography? page =%s ' % page print url content = Urllib2.urlopen (URL) soup = beautifulsoup (content) my_ Girl = soup.findall (' A ', attrs={' class ': ' img '}) for girl in my_ girl: #link = girl.get (' src ') girlink = girl.get (' href ') #先获取首页每个美女图片的进入链接 print Girlink response = urllib2.urlopen (Girlink) per_soup = beautifulsoup (response) img_urls = per_soup.findall (' img ', attrs={' class ': None}) #print img_urls for img _url in img_urls: Girlurl = img_url.get (' src ') print girlurl #获取单个美女的所有图片链接 content2 = urllib2.urlopen (Girlurl). Read () with&nbSp;open (U ' sexy ' + '/' +time.strftime ('%h%m%s ') +str (Random.randint (1000,9999)), ' WB ') as code: code.write (Content2) Page_loop ()
As follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/73/E1/wKioL1YJDgDDT0EUAALvokfzBTI986.jpg "title=" QQ picture 20150928175232.jpg "alt=" Wkiol1yjdgddt0euaalvokfzbti986.jpg "/>
This article is from the "tireless learning ..." Blog, be sure to keep this source http://jonyisme.blog.51cto.com/3690784/1698895
Python Crawl Beauty Pictures