Python Forum
Downloading And Saving Zip Files To A Particular Path Folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Downloading And Saving Zip Files To A Particular Path Folder
#1
Hi there,

How would I alter the following Code, so that when the .Zip Files are downloading, they are saved to a Particular Specified Folder on my Computer, depending on, a specific part of text, they have in the .Zip Filename ?

For example, say I wanted all .Zip Files, which had 737-400 in the Filename or 737-800, saved to :-

C:\Users\Edward\PAI Aircraft\Boeing\B737-400

And

C:\Users\Edward\PAI Aircraft\Boeing\B737-800

Respectively

All .Zip Files which had 320-200 in the Filename, saved to :-

C:\Users\Edward\PAI Aircraft\Airbus\A320-200

All .Zip Files which had 195-200 in the Filename, saved to :-

C:\Users\Edward\PAI Aircraft\Embraer\E195-200

All .Zip Files that didn't fit, into a particular specified Category, saved to :-

C:\Users\Edward\PAI Aircraft\Misc

etc etc.

This is the last bit, of the Python Code I have :-

def download(all_planes):
    '''Download zip for 1 plain,feed with more url download all planes'''
    # A_300 = next(all_planes())  # Test with first link
    how_many_planes = islice(all_planes(), 0, 10)
    for plane_url in how_many_planes:
        url_get = requests.get(plane_url)
        soup = BeautifulSoup(url_get.content, 'lxml')
        td = soup.find_all('td', class_="text", colspan="2")
        zip_url = 'http://web.archive.org/web/20041108022719/http://www.projectai.com:80/libraries/download.php?fileid={}'
        for item in tqdm(td):
            zip_name = item.text
            zip_number = item.find('a').get('href').split('=')[-1]
            with open(zip_name, 'wb')  as f_out:
                down_url = requests.get(zip_url.format(zip_number))
                f_out.write(down_url.content)
  
if __name__ == '__main__':
    download(all_planes)
Any help would be appreciated

P.S. Is that part of the Python Code I posted, sufficient for people, to help me, with answering my question ?
Or do I need to post, the Full Python Code ?

Regards

Eddie Winch
Reply


Messages In This Thread
Downloading And Saving Zip Files To A Particular Path Folder - by eddywinch82 - Jan-05-2020, 11:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create dual folder on different path/drive based on the date agmoraojr 2 462 Jan-21-2024, 10:02 AM
Last Post: snippsat
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 578 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Rename files in a folder named using windows explorer hitoxman 3 767 Aug-02-2023, 04:08 PM
Last Post: deanhystad
  Downloading time zone aware files, getting wrong files(by date))s tester_V 9 1,064 Jul-23-2023, 08:32 AM
Last Post: deanhystad
  Rename all files in a folder hitoxman 9 1,530 Jun-30-2023, 12:19 AM
Last Post: Pedroski55
  does not save in other path than opened files before icode 3 930 Jun-23-2023, 07:25 PM
Last Post: snippsat
  How to loop through all excel files and sheets in folder jadelola 1 4,540 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  python gzip all files from a folder mg24 3 4,066 Oct-28-2022, 03:59 PM
Last Post: mg24
  delete all files and subdirectory from a main folder mg24 7 1,647 Oct-28-2022, 07:55 AM
Last Post: ibreeden
  Merge all json files in folder after filtering deneme2 10 2,386 Sep-18-2022, 10:32 AM
Last Post: deneme2

Forum Jump:

User Panel Messages

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