Jan-05-2020, 11:05 PM
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 :-
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
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