Start New Discussion Reply to this Discussion need help with python prog to download wallpaper from particula site
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
Related Article: python program that supplies data to a site
is a solved Python discussion thread by iwanttolearnc that has 2 replies, was last updated 2 years ago and has been tagged with the keywords: html, python.
hemant_rajput
Newbie Poster
11 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
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()
Sinnocence
Newbie Poster
10 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
hi Sinnocence : i think you made some mistake at line no. 40. what actually you are referring to is not at all defined.
hemant_rajput
Newbie Poster
11 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0665 seconds
using 2.66MB