<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'My first Python program' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'My first Python program' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 15:19:30 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 15:19:30 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>My first Python program</title>
      <link>http://www.programmersheaven.com/mb/python/427074/427074/my-first-python-program/</link>
      <description>Hey everyone, I just joined this board and look forward to being a part of the community here. Last night I was bored and decided I'd learn some Python, so I created my first program last night...so here it is. Don't be too hard on me, as this is my first program (I'm sure it could be optimized and could handle exceptions and input errors)... but anyways, the program is for downloading sequenced images from websites. Here's a sample of some input:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Blue;"&gt;URL of image folder:&lt;br /&gt;
&lt;a href="http://www.gamersglobe.co.uk/screenshot/"&gt;http://www.gamersglobe.co.uk/screenshot/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Image prefix:&lt;br /&gt;
world-of-warcraft-pc-0&lt;br /&gt;
&lt;br /&gt;
First image number:&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
Last image number:&lt;br /&gt;
15&lt;br /&gt;
&lt;br /&gt;
Leading 0 (this is for images 1-9 if for example image 1 is seen as 01) (y/n):&lt;br /&gt;
y&lt;br /&gt;
&lt;br /&gt;
Extension:&lt;br /&gt;
jpg&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The default download folder is &lt;span style="color: Green;"&gt;C:\Images\&lt;/span&gt;&lt;br /&gt;
if the folder doesn't already exists, the program creates it.&lt;br /&gt;
&lt;br /&gt;
There is an error right now, where if there is a leading 0, it will download 10.jpg and 010.jpg&lt;br /&gt;
&lt;br /&gt;
Also, the program will only work for less than 100 images if there is a leading 0.&lt;br /&gt;
&lt;br /&gt;
Anyways, here's the code:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Orange;"&gt;import urllib;&lt;br /&gt;
import os;&lt;br /&gt;
import random;&lt;br /&gt;
&lt;br /&gt;
os.chdir('c:\\');&lt;br /&gt;
&lt;br /&gt;
if os.path.exists('C:\\Images'):&lt;br /&gt;
	os.chdir('C:\\Images');&lt;br /&gt;
else:&lt;br /&gt;
	os.system('mkdir Images');&lt;br /&gt;
	os.chdir('C:\\Images');&lt;br /&gt;
&lt;br /&gt;
print('Enter URL of image folder: ');&lt;br /&gt;
picture_page = raw_input();&lt;br /&gt;
&lt;br /&gt;
print('Enter image prefix: ');&lt;br /&gt;
img_prefix = raw_input();&lt;br /&gt;
&lt;br /&gt;
print('Enter starting image number: ');&lt;br /&gt;
img_fnum = raw_input();&lt;br /&gt;
&lt;br /&gt;
print('Enter last image number: ');&lt;br /&gt;
img_lnum = raw_input();&lt;br /&gt;
&lt;br /&gt;
print('Leading 0 (y/n): ');&lt;br /&gt;
lead0 = raw_input();&lt;br /&gt;
&lt;br /&gt;
print('Enter file extension: ');&lt;br /&gt;
ext = raw_input();&lt;br /&gt;
&lt;br /&gt;
a = range(int(img_lnum));&lt;br /&gt;
&lt;br /&gt;
for x in a:&lt;br /&gt;
	if lead0 == 'y':&lt;br /&gt;
		if x &amp;lt; 10:&lt;br /&gt;
			a[int(x)] = '0' + str(x+1);&lt;br /&gt;
	else:&lt;br /&gt;
		a[int(x)] = str(x+1);&lt;br /&gt;
&lt;br /&gt;
rfolder = random.random();&lt;br /&gt;
rfolder = rfolder * 7397;&lt;br /&gt;
rfolder = str(int(rfolder));&lt;br /&gt;
os.system('mkdir ' + rfolder);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for x in a:&lt;br /&gt;
		print('Source: ' + picture_page + img_prefix + str(a[int(x)-1]) + '.' + ext);&lt;br /&gt;
		print('Destination: ' + os.getcwd() + '\\' + rfolder + '\\' + img_prefix + str(a[int(x)-1]) + '.' + ext);&lt;br /&gt;
		urllib.urlretrieve(picture_page + img_prefix + str(a[int(x)-1]) + '.' + ext, os.getcwd() + '\\' + rfolder + '\\' + img_prefix + str(a[int(x)-1]) + '.' + ext);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have any suggestions or tips please let me know!&lt;br /&gt;
Thanks!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/427074/427074/my-first-python-program/</guid>
      <pubDate>Sat, 28 Jan 2012 10:28:35 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: My first Python program</title>
      <link>http://www.programmersheaven.com/mb/python/427074/427076/re-my-first-python-program/#427076</link>
      <description>Crap, I'm sorry, I didn't mean to post twice!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/427074/427076/re-my-first-python-program/#427076</guid>
      <pubDate>Sat, 28 Jan 2012 10:52:10 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>