I want to write my scraped data into a dictionary using python. the format for the output is :
{‘title’ :{‘author_name’:{‘price’:150}},….}
can anyone give me an idea to do with python?
this is an urgent requirement for me, so can anyone give me an idea to do with python?
thanks in advance.
My_code:
def books():
country = str(input('Enter the country:')
driver = open_driver_connection()
title = ('In Search of Lost Time','Ulysses','Don Quixote','The Great Gatsby','War and Peace')
for lists in title:
driver.get('url')
driver.find_element(By.XPATH, " search box").send_keys(lists)
driver.find_element(By.XPATH, "xpath of the country in search box").send_keys(country)
driver.find_element(By.XPATH, " for submit").click()
elems = driver.find_elements_by_xpath("list of websites for the best search")
hrefs =()
for href in hrefs:
driver.get(href)
try:
try:
price = driver.find_element_by_xpath("").text
except:
price = driver.find_element_by_xpath("other path for few links").text
except:
price = ("Price not mentioned")
author_name = driver.find_element(By.XPATH, " ").text
driver.quit()
books()