archives
- July 2008 (7)
- June 2008 (5)
- May 2008 (5)
- April 2008 (10)
- March 2008 (13)
- February 2008 (3)
- January 2008 (7)
- December 2007 (7)
- November 2007 (9)
- October 2007 (10)
- September 2007 (1)
blogroll
30
Apr
I recently started a contest for a logo design (The link is not to my contest, just an example). Soon I had over 60 entries and I needed an easy way to present these logos to the client in a Power Point presentation. It takes two clicks to get to each image… no good. Thus the following script was created. It should serve as a good tutorial on how to use Python to do some basic web interactions.
#!/usr/bin/python import urllib import re # Change the variables "contest" and "path"
def retrieveImage( contest, path, name ):
url = "http://99designs.com/contests/" + contest + "/entries/" + name
urllib.urlretrieve( url, path + name )
if __name__ == '__main__':
contest = "6999" #The 99designs content number from which you want to extract images
path = "../tmp/" #The path where you want to store the downloaded images
url = urllib.urlopen( "http://99designs.com/contests/" + contest + "/feed" )
url_string = url.read()
p = re.compile( '\d*.large.\w{3,3}' )
iterator = p.finditer( url_string )
for match in iterator:
retrieveImage( contest, path , match.group() )
about
This blog provides programming, design, business and productivity content for tech entrepreneurs living in a 2.0 world.
Find out more about the author here.
categories
- Blogging (1)
- Business (33)
- FireFox 3 (1)
- General (4)
- Holiday (1)
- Life Hacks (18)
- Marketing (5)
- offbeat (2)
- Personal Development (7)
- Podcasting (1)
- Programming (10)
- Reviews (1)
- Sales (5)
- Social Networking (4)
- Symfony (1)
- Ubuntu (7)
- Video (3)
members
most commented post
- » Managing Your Life With GTD, Online Tools and a File Cabinet - 18
- » What Online Social Media Networks Do You Participate In? - 10
- » 19 Secrets From LA's Top SEO Firm - 10
- » The Story Behind iPhone.com - 10
- » Plurk Unleashed! - 10
- » How To Download Ustream.tv Videos - 9
- » CSS Equivalent of Prototype? - 7
- » What Mark Cuban Taught Me About Blogging - 6
- » Thoughts are Things - 6
- » 11 Traffic Tips From the Number One Chiropractic Blog in the World - 6
recent entries
- Quick Tip: Open Office 2.4 Styles
- Running Microsoft Office 2007 Under Wine 1.0 in Ubuntu Hardy Heron 8.04
- Marketing and Promoting Your Company On a Small Budget
- Identity Theft & Fraud
- An Amazing Act of Honesty
- Internal Branding
- Fourth of July Fun in Southern California
- Are Your FireFox 3 Fonts Ugly in Ubuntu Hardy?
- Installing VMWare Server 2 Beta in Ubuntu Hardy 64bit
- Plurk Unleashed!
recent comments
- Isa: It’s always nice to hear about things like this. Honesty and consideration of this kind give me hope for...
- smagnolia: That’s great and thanks for posting it! Peace………R 30;…..
- Dany: I am using http://www.taskwriter.com, combined with Gmail and Google Calendar. I’ve tried to use RTM, but...
- Scam: Another preventative measure would be to take advantage of the 3 free credit reports you can receive each year...
- Lyndon: Ross I stand to be corrected as I am not an expert in this field. But, I have read his estate when he died...
Wordpress theme by Wordpress Themes & made free by Internet Marketing Center
Copyright 2008, ThinkingSerious.com


May 2 2008
Overkill IMO. A less trivial example is going to get large and messy quickly. What about when the XML file in on an FTP, or requires authentication, needs some cookie, has to filter downloads by file size, wants to use a proxy, spawn multiple processes and so on? A more apt tool is curl or wget (I’m lazy so I used both). Also, when you keep it at the shell it’s more natural to pull in other shell commands when needed.
curl -s http://99designs.com/contests/6999/feed | grep -Po “src=\”.*(png|jpg)” | grep -o “http.*” | xargs wget -q
May 2 2008
Great example. Thanks for your contribution.