Skip to content

Commit

Permalink
Merge pull request #9 from paulovictorls/paulovictor
Browse files Browse the repository at this point in the history
feat | gets the monthly condo fee
  • Loading branch information
GeovRodri authored Dec 17, 2021
2 parents 51303cd + f4b7ba8 commit 6bf2046
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ zap.search(localization="go+goiania++setor-oeste", num_pages=5)
* default: 'casas'
* dictionaty\_out (boolean): Specifies the method output (list of objects or dictionary)
* default: False
* time_to_wait (float): time to wait until the script scrapes the next page
* default: 0

#### Scraped attributes:
The objects returned from `search` contain the following attributes:
* description: property description
* price: property price (monthly)
* condo\_fee: property condo fee (monthly)
* bedrooms: number of bedrooms on property
* bathrooms: number of bathrooms on property
* total\_area\_m2: property area (square meters)
* vacancies: parking spots available on property
* address: property address
* link: link of the property
* link: link of the property
11 changes: 7 additions & 4 deletions zapimoveis_scraper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
import json
import time

from zapimoveis_scraper.enums import ZapAcao, ZapTipo
from zapimoveis_scraper.item import ZapItem
Expand Down Expand Up @@ -76,7 +77,7 @@ def convert_dict(data):
#start dictonary
dicts = defaultdict(list)
#create a list with the keys
keys = ['price','bedrooms','bathrooms','vacancies','total_area_m2','address','description', 'link']
keys = ['price', 'condo_fee', 'bedrooms','bathrooms','vacancies','total_area_m2','address','description', 'link']

#simple for loops to create the dictionary
for i in keys:
Expand All @@ -99,6 +100,7 @@ def get_ZapItem(listing):
item = ZapItem()
item.link = listing['link']['href']
item.price = listing['listing']['pricingInfos'][0].get('price', None) if len(listing['listing']['pricingInfos']) > 0 else 0
item.condo_fee = listing['listing']['pricingInfos'][0].get('monthlyCondoFee', None) if len(listing['listing']['pricingInfos']) > 0 else 0
item.bedrooms = listing['listing']['bedrooms'][0] if len(listing['listing']['bedrooms']) > 0 else 0
item.bathrooms = listing['listing']['bathrooms'][0] if len(listing['listing']['bathrooms']) > 0 else 0
item.vacancies = listing['listing']['parkingSpaces'][0] if len(listing['listing']['parkingSpaces']) > 0 else 0
Expand All @@ -109,7 +111,7 @@ def get_ZapItem(listing):
return item


def search(localization='go+goiania++setor-marista', num_pages=1, acao=ZapAcao.aluguel.value, tipo=ZapTipo.casas.value, dictionary_out = False):
def search(localization='go+goiania++setor-marista', num_pages=1, acao=ZapAcao.aluguel.value, tipo=ZapTipo.apartamentos.value, dictionary_out = False, time_to_wait=0):
page = 1
items = []

Expand All @@ -124,8 +126,9 @@ def search(localization='go+goiania++setor-marista', num_pages=1, acao=ZapAcao.a
items.append(get_ZapItem(listing))

page += 1

time.sleep(time_to_wait)

if dictionary_out:
return convert_dict(items)

return items
return items
1 change: 1 addition & 0 deletions zapimoveis_scraper/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ZapItem:

description = None
price = None
condo_fee = None
bedrooms = None
bathrooms = None
total_area_m2 = None
Expand Down

0 comments on commit 6bf2046

Please sign in to comment.