![]() |
|
[Python] Automatically downloading pictures & combining them into an eBook - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Automatically downloading pictures & combining them into an eBook (/showthread.php?tid=4688727) Pages: Pages
1
2
|
Automatically downloading pictures & combining them into an eBook - 0fftime - Feb 16, 2015 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 * - bytecoder - Feb 16, 2015 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. * - 0fftime - Feb 16, 2015 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? * - bytecoder - Feb 16, 2015 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. * - dberube - Feb 16, 2015 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 * - Misingnoglic - Feb 16, 2015 You can download a file easily by doing this: Code import urllibyou can make this into a for loop to download a bunch of images and then name them accordingly Code for x in range(100):* - bytecoder - Feb 17, 2015 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. * - 0fftime - Feb 17, 2015 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!! * - bytecoder - Feb 17, 2015 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. * - 0fftime - Feb 17, 2015 I'll pm you my mail address! Thanks a lot by the way!! * - bytecoder - Feb 17, 2015 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. * - 0fftime - Feb 17, 2015 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!! * - Feanor - Feb 17, 2015 Your could probably hack that together in Ubot with little to no guidance if you don't find an answer here. * - bytecoder - Feb 17, 2015 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 * - 0fftime - Feb 18, 2015 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! |