import requests
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0',
}
r = requests.get("http://pyclass.com/real-estate/rock-springs-wy/LCWYROCKSPRINGS/", headers=headers)
c = r.content
soup = BeautifulSoup(c, "html.parser")
all = soup.find_all("div", {"class": "propertyRow"})
for item in all:
print(item.find("h4", {"class": "propPrice"}).text.replace("\n", "").replace(" ", ""))
print(item.find_all("span", {"class": "propAddressCollapse"})[0].text)
print(item.find_all("span", {"class": "propAddressCollapse"})[1].text)
try:
print(item.find("span", {"class": "infoBed"}).find("b").text)
except:
print(None)
try:
print(item.find("span", {"class": "infoValueFullBath"}).text)
except:
print(None)
try:
print(item.find("span", {"class": "infoSqFt"}).text)
except:
print(None)
try:
print(item.find("span", {"class": "infoValueHalfBath"}).text)
except:
print(None)
for column_group in item.find_all("div", {"class":"columnGroup"}):
print(type(column_group))
for feature_group, feature_name in zip(column_group.find_all("span", {"class":"feature_Group"}),column_group.find_all("span", {"class":"feature_Name"})):
if "Lot Size" in feature_group.text:
print(feature_name.text)
print(" ")