I am new to BeautifulSoup and scraping different question-answers pair from Quora
on the topic 'GRE' link.
After scraping, I viewed the scraped question-answer pair and noticed that the ordering of the scraped pair is different from the one that is actually in the website.
From this question, the answer says that find_all
does preserve the order, but using find_all
didn't help preserve the order in my case.
Am I going wrong somewhere ? Kindly help !!
Here is the code for the scraping:
from bs4 import BeautifulSoup
import requests
r = requests.get('https://www.quora.com/topic/Graduate-Record-Examination-GRE-1')
soup = BeautifulSoup(r.text,'lxml')
#print(soup.prettify())
#match = soup.title
#match
#match.text
#a = soup.find('link', id_ = 'wxlJClxd1')
#a = soup.find('div', class_ = 'AnswerStoryBundle Bundle')#.find('div', id_ = '__w2_waNcSF3r41_paged_list')
a = soup.find_all('div',{'class':'AnswerStoryBundle Bundle'})
for i in a:
print(i.text,'\n')
---------
I can't understand why a difference in the ordering taking place?