I'm downloading books from the website, and almost my code runs smoothly, but when I try to open the pdf Book on my PC. An error generated by Adobe Acrobat Reader that this is not supported file type.
Here is the image of the Book formate, and I'm sure my code needs to be a correction because the formate of the book on the website is different from normally PDF Files.
Code:
import requests
from bs4 import BeautifulSoup
url = 'https://global.oup.com/education/support-learning-anywhere/key-resources-online/?region=international&utm_campaign=learninganywhere&utm_source=umbraco&utm_medium=display&utm_content=support_learning_key_resources&utm_team=int#Primary'response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
table_data = soup.find_all('td')books_url_list = []
for link in table_data:books_url = link.find('a')['href']books_url_list.append(books_url+'.pdf')book = books_url_list[1]
book_response = requests.get(book)with open('books.pdf', 'wb') as f:f.write(book_response.content)
`