# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.6.1 64-bit
#     language: python
#     name: python36164biteddb5945131e4a35a21d1f6554c5511d
# ---

from selenium import webdriver
import pandas as pd

driver = webdriver.Chrome('E:\Softwares\chromedriver_win32\chromedriver.exe')

driver.get('http://www.gutenberg.org/ebooks/search/%3Fsort_order%3Drelease_date')

books = driver.find_elements_by_class_name('booklink')
len(books)

print(books[0].text)

print(books[-1].text)

name = books[0].find_elements_by_class_name('title')[0].text
author = books[0].find_elements_by_class_name('subtitle')[0].text
date = books[0].find_elements_by_class_name('extra')[0].text
print(name)
print(author)
print(date)

name = books[-1].find_elements_by_class_name('title')[0].text
# author = books[-1].find_elements_by_class_name('subtitle')[0].text
date = books[-1].find_elements_by_class_name('extra')[0].text
print(name)
print(author)
print(date)

for book in books[:5]:
    try:
        name = book.find_elements_by_class_name('title')[0].text
        try:
            author = book.find_elements_by_class_name('subtitle')[0].text
        except:
            author = 'Not availbale'
        try:
            date = book.find_elements_by_class_name('extra')[0].text
        except:
            date = 'Not availbale'
        print('name:', name)
        print('author :', author)
        print('date :', date)
        print('_'*100)
    except:
        pass



StarcoderdataJupyterScriptsDedupFiltered