My code looks like crap and I need help getting it to work.

Hewlett-packard Pavilion dv6-2190us note...
April 28, 2012 at 00:42:53
Specs: Win 7, Core i5 / 4 gigs

n=raw_input('Please specify the current year [example: 2000]: ')
print "Hello Please Wait"
print "the program is downloading your files"

year1=2007

while (year1 < n):
    year1=year1+1
    year2=year1+1
    import urllib2 
    import sys
def url():
    sys.stdout.write('http://www.nauanimeclub.com/')
    sys.stdout.write(year1)
    sys.stdout.write('-')
    sys.stdout.write(year2)
    sys.stdout.write('.php')
     
    url = url()
    
    file_name = url.split('/')[-1] 
    u = urllib2.urlopen(url) 
    f = open(file_name, 'wb') 
    meta = u.info() 
    file_size = int(meta.getheaders("Content-Length")[0]) 
    print "Downloading: %s Bytes: %s " % (file_name, file_size)
     
    file_size_dl = 0 
    block_sz = 8192 
    while True: 
        buffer = u.read(block_sz) 
        if not buffer: 
            break 
     
        file_size_dl += len(buffer) 
        f.write(buffer) 
        status = r"%10d  [%3.2f%%] " "\n" % (file_size_dl, file_size_dl * 100. / file_size)
        status = status + chr(1)
        print '\n'*100
        print status,
     
    f.close() 

edited by moderator: Added pre tags -Razor2.3


See More: My code looks like crap and I need help getting it to work.

Report •


#1
April 28, 2012 at 01:12:01
So, what is it supposed to do?

What does it do?

What is your question?


Report •

#2
April 28, 2012 at 08:08:14
Sorry I thought the code would be kinda self explanatory...

The objective i'm trying to pull off here is to get a file to download from a particular website. and continue to download for each year.

it will start off with the year 2007 and then stop at the year the user inputted.

so for example

>>>please enter the current date: 2012

please wait while the files download...

downloading from: www.someurl.net

www.someurl.net/2007-2008.php
downloading file: 100%
www.someurl.net/2008-2009.php
downloading file: 100%
www.someurl.net/2009-20010.php
downloading file: 100%
www.someurl.net/2010-20011.php
downloading file: 100%
www.someurl.net/2011-2012.php
downloading file: 100%

all your files have been downloaded.


Report •

#3
April 28, 2012 at 12:51:09
You still haven't explained what your problem is. Is the program not working? What is happening?

Unless you actually ask a question it's very difficult to give an answer.

I'm giving up on this one because I have no idea what you want. Perhaps someone more patient than I am will be able to help if you explain what your question is.


Report •

Related Solutions


Ask Question