Generation

generate functionThu, 23 Mar 2023

Write code in Python that downloads all the text file names at url: http://stup.pro/wp-content/uploads/2023/03/*.txt into one list of book_files

import requests from bs4 import BeautifulSoup def get_book_files(url): text_files = [] resp = requests.get(url) soup = BeautifulSoup(resp.text, 'lxml') for link in soup.find_all('a', href=True): if '.txt' in link['href']: text_files.append(link['href']) return text_files books = get_book_files('http://stup.pro/wp-content/uploads/2023/03/') print(books)

Questions about programming?Chat with your personal AI assistant