Open sfksuperman opened 3 years ago
`import urllib.request import urllib, sys
def report(blocknr, blocksize, size): current = blocknrblocksize sys.stdout.write("\r{0:.2f}%".format(100.0current/size))
def downloadFile(url): fname = url.split('/')[-1] urllib.request.urlretrieve(url, fname, report) print ("Download starting...")
tld = "http://www.tutorialspoint.com/"
print ("Name of Tutorial? ") query = input() url = tld+query+'/'+query+'_tutorial.pdf' downloadFile(url) print ("\nComplete PDF for " + query + " has been downloaded\n") `
Tried your updated code it also have too much errors
python3
import urllib.request
import sys
def report(blocknr, blocksize, size):
current = blocknr * blocksize
if size > 0:
percent = 100.0 * current / size
sys.stdout.write("\r{0:.2f}%".format(percent))
sys.stdout.flush()
def downloadFile(url):
fname = url.split('/')[-1]
print("Download starting...")
urllib.request.urlretrieve(url, fname, report)
print("\nDownload complete.")
tld = "http://www.tutorialspoint.com/"
print("Name of Tutorial? ")
query = input()
url = tld + query + '/' + query + '_tutorial.pdf'
downloadFile(url)
print("\nComplete PDF for " + query + " has been downloaded\n")
I installed Git in my pc and followed the step (cloned using your line
git clone https://github.com/manojitballav/Tutorialspoint-pdf-downloader.git
). Now, you said to runpython pdf-generator.py
but it's giving me error.