This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adiciona pycache e corrige texto * Busca pagamentos um dia antes * Adiciona opcao 'all' ao comando * Adiciona instruções
- Loading branch information
1 parent
89c581c
commit 9ca5ddf
Showing
4 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ __pycache__ | |
.scrapy/ | ||
.vscode | ||
.env | ||
.pytest_cache | ||
|
||
# data | ||
*.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import argparse | ||
from datetime import datetime, timedelta | ||
|
||
from scrapy.crawler import CrawlerProcess | ||
from scrapy.utils.project import get_project_settings | ||
|
||
|
||
def run_crawlers(start_date): | ||
process = CrawlerProcess(get_project_settings()) | ||
|
||
process.crawl("cityhall_payments", start_date=start_date) | ||
process.start() | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--all", help="Coleta todos os itens desde a data inicial.", action="store_true" | ||
) | ||
args = parser.parse_args() | ||
if args.all: | ||
start_date = None | ||
else: | ||
yesterday = datetime.now() - timedelta(days=1) | ||
start_date = yesterday.date() | ||
|
||
run_crawlers(start_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters