Чтобы получить все атрибуты title
для обложек книг, вы можете использовать селектор CSS .book-cover-image img[title]
(выбрать все <img>
теги с атрибутом title
, которые находятся под тегом с классом book-cover-image
):
import requests
from bs4 import BeautifulSoup
url = 'https://www.downtoearth.org.in/books'
soup = BeautifulSoup(requests.get(url).text, 'lxml')
for i, img in enumerate(soup.select('.book-cover-image img[title]'), 1):
print('{:>4}\t{}'.format(i, img['title']))
Печать:
1 State of India’s Environment 2019: In Figures (eBook)
2 Victim Africa (eBook)
3 Frames of change - Heartening tales that define new India
4 STATE OF INDIA’S ENVIRONMENT 2019
5 State of India’s Environment In Figures 2018 (eBook)
6 Getting to know about environment
7 CLIMATE CHANGE NOW - The Story of Carbon Colonisation
8 Climate change - For the young and curious
9 Conflicts of Interest: My Journey through India’s Green Movement
10 Body Burden: Lifestyle Diseases
11 STATE OF INDIA’S ENVIRONMENT 2018
12 DROUGHT BUT WHY? How India can fight the scourge by abandoning drought relief
13 SOE 2017 (Print version) and SOE 2017 in Figures (Digital version) combo offer
14 State of India's Environment 2017 In Figures (eBook)
15 Environment Reader for Universities
16 Not in My Backyard (Book & DVD combo offer)
17 The Crow, Honey Hunter and the Kitchen Garden
18 BIOSCOPE OF PIU & POM
19 SOE 2017 and Food book combo offer
20 FIRST FOOD: Culture of Taste
21 Annual State Of India’s Environment - SOE 2017
22 An 8-million-year-old mysterious date with monsoon (e-book)
23 Why I Should be Tolerant
24 NOT IN MY BACKYARD – Solid Waste Mgmt in Indian Cities