#!/usr/bin/env python
import re, os
from urllib2 import urlopen
all_tag = []
def search_tag():
index_page = 'http://wallbase.net'
try:
_page_ = urlopen(index_page)
_html_ = _page_.readlines()
_page_.close()
p = re.compile(r'http://wallbase\.net/search/[a-z]+\"')
for line in _html_:
tag = p.findall(line)
if tag:
for i in tag:
all_tag.append(i[:-1a])
else:
continue
except Exception, e:
print "Connection Error!" + str(e)
def getsession(num):
org_url = "http://wallbase.net/wallpaper/"
second_url = org_url + num
_prefix = "http://wallpapers.yotoon.pl/rozne/"
ext = '.jpg'
fullname = "wallpaper-" + num + ext
try:
_page_ = urlopen(second_url)
_html_ = _page_.readlines()
_page_.close()
for line in _html_:
st = line.find(_prefix)
nd = line.find(fullname)
if st <> -1 and nd <> -1:
final = line[st:nd] + fullname
print final
os.system('wget ' + final)
else:
continue
except Exception, e:
print "Cannot connect to server!" + str(e)
pass
def getnum(list_tag):
for page in list_tag:
try:
response = urlopen(page)
content = response.readlines()
response.close()
for line in content:
a = line.find('thumb-')
b = line.find('jpg')
if a <> -1 and b <> -1:
c = a + 6
d = b - 1
number= line[c:d]
getsession(number)
continue
else:
continue
except:
print "May be we got wrong image url!"
if __name__ == '__main__':
search_tag()
getnum(all_tag)
exit()
Net chậm thì down chắc mất cả tháng :-D
26 Jun 2010
Down hết hình trên wallbase.net
Subscribe to:
Post Comments (Atom)
2 comments:
Hi Mr Hung
When i run this script. I get the error
File "wallpaper.py", line 17
all_tag.append(i[:-1a])
^
SyntaxError: invalid syntax
Can you ?
sorry :), just remove 'a',its should works.
==========
all_tag.append(i[:-1])
==========
Post a Comment