Fixed name and address

Now prints out name and address of located apartments
This commit is contained in:
Nico Melone
2022-05-10 14:02:17 -05:00
parent 13ed28bfbb
commit 3ba3288ef4

View File

@@ -3,12 +3,12 @@ import requests
from bs4 import BeautifulSoup
from selenium import webdriver
#list of Cities
Cities =["Dallas","Fort Worth","Arlington","Plano","Irving","Denton","Richardson","Grapevine"]
St="tx"
baseurl="https://www.apartments.com/" #baseURL
search ="/max-2-bedrooms-under-1500" #search terms
#driver = webdriver.Chrome()
driver = webdriver.Edge()
x=0
#url = baseurl+'Dallas'+"-"+St+search
@@ -26,8 +26,8 @@ for city in Cities:
soup = BeautifulSoup(src, 'html.parser')
Apartment = soup.find_all('span', class_='js-placardTitle title')
ApartmentAddr = soup.find_all('div', 'property-address js-url')
for span in Apartment:
print(span)
span_soup = BeautifulSoup(span, 'html.parser')
Name = span.find('span', class_='js-placardTitle title')
print(name.string)
for apartment, address in zip(Apartment, ApartmentAddr):
#print(apartment)
Name = apartment.contents[0]
Addr = address.contents[0]
print(Name + ", ", Addr)