Skip to content

Commit

Permalink
feat | add the possibility to set a timer between pages
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovictorls committed Dec 16, 2021
1 parent eede875 commit f4b7ba8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ 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:
Expand Down
6 changes: 4 additions & 2 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 @@ -110,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 @@ -125,7 +126,8 @@ 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)

Expand Down

0 comments on commit f4b7ba8

Please sign in to comment.