Use Python to capture the CSS template of the template house and python to capture the css Template
The Python version is 2.7.9. If it is successfully tested on win8, it is a little slow to capture. If you want to use multiple threads, you have to wait. The url parameter on the website of the template home does not match the page number. If you are too lazy to perform analysis, change the url in the code. Do not spray!
Copy codeThe Code is as follows:
#! /Usr/bin/env python
#-*-Coding: UTF-8 -*-
# By ustcwq
#2015-03-
Import urllib, urllib2, OS, time
From bs4 import BeautifulSoup
Start = time. clock ()
Path = OS. getcwd () + U'/template home capture template /'
If not OS. path. isdir (path ):
OS. mkdir (path)
Url = "http://www.cssmoban.com/cssthemes/index_80.shtml" # How are the numbers behind the index in the source website organized?
Theme_url = 'HTTP: // www.cssmoban.com/cssthemes /'
Response = urllib2.urlopen (url)
Soup = BeautifulSoup (response)
Result = soup. select ('P [class = "title"] ')
Print result
For item in result:
Link = item ['href ']
# Down_name = item. text # file name
New_url = theme_url + link. split ('/') [-1]
Response = urllib2.urlopen (new_url)
Soup = BeautifulSoup (response)
Result = soup. select ('. btn ')
Down_url = result [1] ['href '] # File Link
Local = path+time.strftime('policy?m=d=h?m=s', time.localtime(time.time({{}}'.zip'
Urllib. urlretrieve (down_url, local) # remote SAVE Function
End = time. clock ()
Print U' template Capture complete! '
Print u'total time: ', end-start, U' second'
The above is all the content of this article. I hope you will like it.