Hi,

I need wrote a script which can go to particular site and download all the wallpaper or images available there. Can any one suggest me how to start with that. I never wrote python prog before but i know python. If anyone cn give me the direction it will be very helpful.

for example you can take sanatabanta.com

Hi,

I need wrote a script which can go to particular site and download all the wallpaper or images available there. Can any one suggest me how to start with that. I never wrote python prog before but i know python. If anyone cn give me the direction it will be very helpful.

for example you can take sanatabanta.com

What your trying to do is called scraping.
There a few modules that do this, a good place to start would be doing a quick search
on BeautifulSoup.

###BeautifulSoup Tutorial by Sinnocene###

from BeautifulSoup import BeautifulSoup
import re
html = '<head><!-- ViewAd --><title>1997 Acura Integra GS Coupe (rare turbo),  Classifieds Ad ID: 236987424</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>'

smoke = '<tr><td nowrap valign=top class="first_col " >Price</td><td style="font-weight:bold"> <strong>$5,000.00</strong>'

soup = BeautifulSoup(html)
soup1 = BeautifulSoup(smoke)

commentSoup = BeautifulSoup(html)
comment = commentSoup.find(text=re.compile("ViewAd"))

#exact destination of the <title>#
title = soup.head.title

#recovers the price from <strong>#
price = soup1.tr.strong

#recovers the total amount of tags inside soup1#
total = len(soup1.strong)
if total > 2:
    print total
    
#search for all <head> & <title> tags#
search = soup.findAll(['head','title'])

#finds all tags with [1] tag inside them#
total = soup1.findAll(lambda tag: len(tag.attrs) == 1)

#finds all tags with a alignment of "center"#
alignment = soup1.findAll(align="center")

#finds only one tag even if more exist#
find = soup.title.find(text="Integra")

#finds all links that exist within specified code#
for link in smoke:
    print link['href']


#prints everything#
print title;
print price;

if alignment == True:
    print alignment
else:
    print 'zero';
    

print '---------------------------\n'
print find;
print soup.prettify()

hi Sinnocence : i think you made some mistake at line no. 40. what actually you are referring to is not at all defined.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.