I'm scraping some information and below is my code
from bs4 import BeautifulSoup
import requests
url = "https://www.privateproperty.com.ng/property-for-sale"
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find_all('div', class_="similar-listings-item sponsored-listing")
for result in results:
Title = result.find('div', class_= "similar-listings-info").text.replace('\n','')
location = result.find( class_= "listings-location").text.replace('\n','')
Price = result.find('div', class_= "similar-listings-price").text.replace('\n','')
info = (Title, location, Price)
print(info)
Why does this line
results = soup.find_all('div', class_="similar-listings-item sponsored-listing")
return only the 1st element?
CodePudding user response:
Why does this line
results = soup.find_all('div', class_="similar-listings-item sponsored-listing")
return only the 1st element?