The "title" variable list in line 6, when I tried to run the program, said that the list index was out of range and I am unsure how to correct the error
Complete the Python program below to display the name of the most recently added dataset and collect the total number of datasets currently listed on the URL provided below
!pip install cssselect
from lxml import html
import requests
response = requests.get('http://catalog.data.gov/dataset?q=&sort=metadata_created+desc')
doc = html.fromstring(response.content) #TO DO -- Complete the Code
title = doc.cssselect('h2.dataset-heading')[0].text_content() #TO DO -- Complete the Code
print("The name of the most recently added dataset on data.gov:")
print(title.strip())
response1 = requests.get('http://www.data.gov/')
doc_gov = html.fromstring(response1.content) #TO DO -- Complete the Code
link_gov = doc_gov.cssselect('transalator param')[0] #TO DO -- Complete the Code
print("Number of datasets currently listed on data.gov:")
print(link_gov.text)
The "title" variable list in line 6, when I tried to run the program, said that the list index was out of range and I am unsure how to correct the error
Step by step
Solved in 2 steps