Python Forum
Download some JPG files and make it a single PDF & share it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Download some JPG files and make it a single PDF & share it
#1
I download some jpg files (A4 size) from a website and convert all the files into a single pdf file and email it.

The jpg files are in a url format of:

http://URL.com/RPT/2020/07/26/<page no>

The date today is 2020/7/26 and page number as 2 char (01-15)

How can I automate the whole process so it does it automatically without any thing from me?

My technical background is I learnt MS office packages in school and completed FreeCodeCamp's Responsive Web Design Certification and I am currently doing Automate the Boring Stuff with Python. I am hoping this is "web scraping", not sure how to classify this project.

I just have a laptop, no server or any cloud accounts. So, I am hoping that I can run it program/script (not sure of the difference) on some free service.

Is Google App Script capable of doing what I want?

Pls mention the steps I need to follow or better if you can like me to a tutorial of anyone doing a project similar to mine.
Reply
#2
you should learn how to use python requests package: https://requests.readthedocs.io/en/master/
it can be installed with pip install requests
for binary file (which images are) call like:
get_file('myfile url', bytes=True), otherwise get_file('myfile url')

a simple download would be something like:
import requests

def get_file(url, bytes=False):
    response = requests,get(url)
    if response == 200:
        if bytes:
            return response.content
        else:
            return response.text
    else:
        print(f"Bad status code: {response.status_code}"
        return None # This command is ambiguous and may be eliminated. 

        
Reply
#3
(Jul-27-2020, 08:54 PM)Larz60+ Wrote: you should learn how to use python requests package: https://requests.readthedocs.io/en/master/

how do I run it on a server so that I dont have to run it from my laptop?
Reply
#4
This is just a code snippet that I wrote on the fly.
I expect that you would write additional code around what I suggested here.
Reply
#5
(Jul-29-2020, 09:01 PM)Larz60+ Wrote: This is just a code snippet that I wrote on the fly.
I expect that you would write additional code around what I suggested here.

I want to write my own code. But my question is to run on a server do I have to make it a flask application? I have not written code to run on server, so what do I need to run this code on a server?
Reply
#6
you will need some way to access from server, flask or some other framework.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Please share what can be achieved using Django Middleware? ankitnew 3 4,912 Apr-14-2020, 05:16 PM
Last Post: menator01
  Access my webpage and download files from Python Pedroski55 7 5,530 May-26-2019, 12:08 PM
Last Post: snippsat
  I wan't to Download all .zip Files From A Website (Project AI) eddywinch82 68 37,473 Oct-28-2018, 02:13 PM
Last Post: eddywinch82
  Staying motivated? Share your story. Ceegen 10 5,723 Oct-18-2018, 01:25 PM
Last Post: metulburr
  I Want To Download Many Files Of Same File Extension With Either Wget Or Python, eddywinch82 15 14,347 May-20-2018, 06:05 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020