I want to get the ranking of an host from Airbnb site by scraping the data from the pages with the individual reviews and ranking in the region. I am able to get the number of review from the page but does not have any idea about the ranking. Following is my code
from bs4 import BeautifulSoup # BeautifulSoup is in bs4 package
import requests
URL = input("Please enter an URL to the number of reviews \n")
#'https://www.airbnb.co.in/users/show/154131896'
content = requests.get(URL)
soup = BeautifulSoup(content.text, 'html.parser')
row = soup.find('div')
#Extract and return first occurrence
print("=========Text Result==========")
print(row.get_text())
#Print row as text
divs = soup.find_all('div', { "class" : "_5kaapu"})
#Find all the records for reviews
for i in divs:
childr = i.findChildren("span" , recursive=False)
for child in childr:
iwant = child.text
print(iwant)
contentTable = soup.find('div', { "class" : "_5kaapu"})
# Use dictionary to pass key : value pair
rows = contentTable.find_all('span',{"class": "_1ax9t0a"})
for row in rows:
print(" The host have ", row.get_text())