So i'm scraping MCQs from this site. I want correct option at last. All options share same class='radio-button-click-target'. but the correct option has radio-button-click-target correctquestions at the end. I tried BeautifulSoup webscraping find_all( ): finding exact match solution of custom function but now none of the options are appearing.
import requests
from bs4 import BeautifulSoup
address = 'https://www.ilmkidunya.com/online-test/5th-class-science-english-meduim-mcqs-with-answers?startfrom=0&last=92'
response = requests.get(address)
soup = BeautifulSoup(response.text, 'lxml')
ques_id = soup.find_all('div', class_='q-title')
ques_det = soup.find_all('div', class_='q-desc')
optn_det = soup.find_all('div', class_='choose-answer-block')
for i in range(0, len(ques_id)):
print((ques_id[i].text))
print(str(ques_det[i].text).strip())
options = optn_det[i].find_all(lambda tag: tag.name == 'div' and tag.get('class') == ['radio-button-click-target correctquestions'])
for opn in options:
print(str(opn.text).strip())
print('<----->')
CURRENT OUTPUT
Question # 1
The group which belong to invertebrates is.
amphibians
Worms
Reptiles
Mammals
<----->
Question # 2
The main cause of cholera is:
land polllution
noise pollution
air pollution
water pollution
<----->
Expected OUTPUT
Question # 1
The group which belong to invertebrates is.
amphibians
Reptiles
Mammals
Worms
<----->
Question # 2
The main cause of cholera is:
land polllution
noise pollution
air pollution
water pollution
<----->
Correct Option should be displayed at the end