[Fixed]-How to select data within multiple div when no unique id associated with it

1👍

You can rely on the class attribute:

soup.find("div", class_="content")

Or, with a CSS selector:

soup.select_one("div.content")

If the content class is not something uniquely identifying the element and you know the preceding “Interactive Elements” label:

import re

label = soup.find("div", class_="title", text=re.compile("Interactive Elements"))
print(label.find_next_sibling("div", class_="content"))
👤alecxe

0👍

You can achive this in various waysL

1. document.querySelector('.content').innerHTML;

2. $('.content').text(); / $('.content').html();

3. soup.find("div", class_="content")

4. soup.select_one("div.content")

Leave a comment