Question: #Using the following link: ( the link for the best selling books on the New York Times ) # 1 . Where are the titles

#Using the following link:
(the link for the best selling books on the New York Times)
#1. Where are the titles stored? Copy and paste the HTML Element that contains all the titles
#2. What type of HTML Element does contians the titles
#3.write a script that pulls all of the following information
# - Title
# - Author
# - Publisher
# - Description
# - How Long on the list
# Use the above script to write a loop that stores the above informaiton
# for each week URL will change from above to
'(the url for the best selling books in the New York Times)/books/best-sellers/YEAR/MONTH/DAY/combined-print-and-e-book-nonfiction/'
#where YEAR, MONTH, AND DAY will need to be input through a script
#it is important to note that the NYT only publishes weekly
#so you will need to have a something that tests if you are getting results back
#
# PICK 2 RANDOM DATES THAT ARE NOT THE ONES BELOW
# MAKE SURE IT IS ONE YEAR
#
#with the above information I would like you to add:
# - Date you entered in you URL
# - Week number
from datetime import datetime as dt
from datetime import timedelta
import requests
from bs4 import BeautifulSoup as soup
import pandas as pd # type: ignore
def date_range(start,end,step):
start = dt.strptime(start,'%Y-%m-%d')
end = dt.strptime(end,'%Y-%m-%d')
while start <= end:
yield start
start += timedelta(step)
for x in date_range('2024-10-01','2024-10-30',7):
url = f'(the link to the page)/books/best-sellers/{x.year}/{x.month}/{x.day}/combined-print-and-e-book-nonfiction/'
#r = requests.get(url)
#print(r.status_code) #check if this is 404 pass else write your scrape_code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!