Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Automatically downloading pictures & combining them into an eBook

Hi there!

I've got a request, and was wondering if anyone here could help me out!
This year my school introduced digital books, which in my opinion is quite awesome however, since the licences are digital ones I can only access the books this year. And if I would like to study from it next year or use it as reference I can't. But today I found out that the every single page of the book is a simple png or jpg file. Which even can be accessed without logging into the site of publisher. And since I've just started to learn python (via Learn Python the Hard Way) I thought a python script could help.

What I would like a script a to do is use a certain URL and download the image, the URL is a straight link to the IMG file (which can either be .png or .jpg). And then progress to the next URL by itself. So for instance I would give the URL http://www.google.com/page001.jpg and the script would download that image to a given folder. After that it would go to the next one itself which would be http://www.google.com/page002.jpg. And so on till it ends.

After this I would like to combine all these images in an ebook so that I can easily read through it.

What i think could be a problem that with most books some pages are in .jpg format and others are in .png. This is completely random. That might become a problem with checking the URL's.

Now my question is if someone could be able to help me make this or has something like this available. My python programming knowledge is not that great since I've just started learning, so making this all myself would be kind of a challenge. I would however like to learn from this so that I might be able to fix this kind of issue myself.

Thanks in advance,

0fftime
If you give me the real url (PM if you want it private) I can write some simple scrapper that could do all the work.
I could pm you the URL but it are about 20 some what books, so could i send you 1 URL and then later edit those? So that I can use it in the future for other books aswell?
One url is enough. I got your pm, but cant answer, cause of the "you have to spam 25 posts" - I have go to sleep, but I will code some tool in the next days (2 or 3 - I will constantly update you. Just give me some time :)

Can you sent me your mail address via PM?

Thanks in advance.
Not quite an ebook, but I released something similar not so long ago. Maybe it can help you: https://hackforums.net/showthread.php?tid=4360269
You can download a file easily by doing this:

Code
import urllib
urllib.urlretrieve ("http://www.example.com/songs/mp3.mp3", "mp3.mp3")
(in python 3 I think it's urllib2)

you can make this into a for loop to download a bunch of images and then name them accordingly
Code
for x in range(100):
    urllib.urlretrieve ("http://www.example.com/page"+str(x)+".jpg", str(x)+".jpg")
To make them a PDF I would just find some jpg to pdf utility, probably easier
current situation:

- downloader works for all images
- working on a PDF converter

It will be with a nice configuration-menu, so you can choose your own links, file ends, number of images and so on... :)

some screen of it: cant post whole link: i.imgur.com/pFsPo2W.jpg

edit: PDF Converter is working. Was a pain in the ass, cause the images were in a bad format for size A4.

I will finish some code and will respond again. Maybe I will do a GUI, too.
Thanks a lot for all the suggestions guys! I'm going to wait for bytecoder's script! It looks awesome mate!! Really thanks a lot for that, for my part you wouldn't have to spent time on a GUI unless you really want to ofcoarse!! Thanks a lot again!!
Offtime, can you send me some contact address via PM?

There are some of your personal credentials in the code and I don't want to public them.

I will release the code after I removed all credentials and when it's working for you.
I'll pm you my mail address! Thanks a lot by the way!!
Here is the code.

pastebin.com/d5zqmTq9

Note: The provided URLs where kind of special, so the code will not run for any other random URL.

But you others can look into the code. It's not great, but it works.
Thank you so much!!

I'm trying to run it on my mac right now but get an import error saying there's no module requests? Could this be because I need to install an extra library or something like that?

And does it work with both versions of python? I don't know what my mac is running but on my windows pc I got 2.7 running.


Could you by the way please tell me where and how you learned python? I've started using the book learn python the hard way but after that there ofcoarse is much to learn! And I'd love to be able to make these sorts of programs myself!!
Your could probably hack that together in Ubot with little to no guidance if you don't find an answer here.
requests is a common library.

1. Install this

store.continuum.io/cshop/anaconda/

windows pc (2.7 is good, I used that too)

2. open cmd and enter "pip install requests" without ""

3. run script again. -> I can help you via teamviewer, just mail me.

Edit: I learned Python the same way like you do. I have read the same book. Then another. And so on. Go through other tools and look how other have coded.
reddit.com/r/learnpython
reddit.com/r/dailyprogrammer
You should go there every day . Use google, stackoverflow.com and github.com
I think I need some help.. I installed the anaconda thingy on my dekstop (windows 7) but I still get the requests module missing error.. And when I run pip install requests I get an error aswell!

Could you maybe add me on skype or something like that, that way if we're both online I could pass you my teamviewer ID and you might be able to help me out. By the way thanks alot again this really means a lot to me!

And I'll start checking those reddits out! Never heard of the dailyprogrammar one but when I gather some more programming knowledge that seems like a lot of fun!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by 0u1lawJul 9, 2020 12:48 PM 11 220 Jul 9, 2020 12:48 PM
Last Post: 0u1law
[C#] by Gt403cylJun 12, 2017 11:12 AM 2 157 Jun 12, 2017 11:12 AM
Last Post: Owl
[Shell] by ๖ۣۜSolaceFeb 17, 2016 02:32 PM 1 104 Feb 17, 2016 02:32 PM
Last Post: Pseudonym