-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adiciona novo workflow de raspagem fatiada anualmente (#1316)
- Loading branch information
Showing
8 changed files
with
83 additions
and
7 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
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
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
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,76 @@ | ||
name: Schedule Spider Crawl Split Per Year | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
spider_name: | ||
description: 'Spider to be scheduled' | ||
required: true | ||
start_date: | ||
description: 'Start date (YYYY-MM-Dd")' | ||
required: true | ||
end_date: | ||
description: 'End date (YYYY-MM-Dd")' | ||
required: false | ||
|
||
jobs: | ||
full-crawl-yearly: | ||
runs-on: ubuntu-latest | ||
env: | ||
SHUB_APIKEY: ${{ secrets.SHUB_APIKEY }} | ||
SCRAPY_CLOUD_PROJECT_ID: ${{ secrets.SCRAPY_CLOUD_PROJECT_ID }} | ||
FILES_STORE: ${{ secrets.FILES_STORE }} | ||
QUERIDODIARIO_DATABASE_URL: ${{ secrets.QUERIDODIARIO_DATABASE_URL }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_ENDPOINT_URL: ${{ secrets.AWS_ENDPOINT_URL }} | ||
AWS_REGION_NAME: ${{ secrets.AWS_REGION_NAME }} | ||
SPIDERMON_DISCORD_FAKE: ${{ secrets.SPIDERMON_DISCORD_FAKE }} | ||
SPIDERMON_DISCORD_WEBHOOK_URL: ${{ secrets.SPIDERMON_DISCORD_WEBHOOK_URL }} | ||
ZYTE_SMARTPROXY_APIKEY: ${{ secrets.ZYTE_SMARTPROXY_APIKEY }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
- name: Prepare environment | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install click python-decouple scrapinghub SQLAlchemy psycopg2 | ||
- name: Schedule full crawl per year | ||
if: ${{ !github.event.inputs.end_date }} | ||
run: | | ||
cd data_collection/ | ||
spider=${{ github.event.inputs.spider_name }} | ||
start_date=${{ github.event.inputs.start_date }} | ||
int_start_date=$(date -d $start_date +"%Y%m%d") | ||
int_end_date=$(date --date="today" +"%Y%m%d") | ||
while [[ $int_start_date -lt $int_end_date ]]; do | ||
int_date_to=$(date -d"$int_start_date + 1 year" +"%Y%m%d") | ||
if [[ $int_date_to -ge $int_end_date ]]; then | ||
int_date_to="$int_end_date" | ||
fi | ||
date_from=$(date -d"$int_start_date" +"%Y-%m-%d") | ||
date_to=$(date -d"$int_date_to" +"%Y-%m-%d") | ||
python scheduler.py schedule-spider --spider_name="$spider" --start_date="$date_from" --end_date="$date_to" | ||
int_start_date="$int_date_to" | ||
done | ||
- name: Schedule partial crawl per year | ||
if: ${{ github.event.inputs.end_date }} | ||
run: | | ||
cd data_collection/ | ||
spider=${{ github.event.inputs.spider_name }} | ||
start_date=${{ github.event.inputs.start_date }} | ||
end_date=${{ github.event.inputs.end_date }} | ||
int_start_date=$(date -d $start_date +"%Y%m%d") | ||
int_end_date=$(date -d $end_date +"%Y%m%d") | ||
while [[ $int_start_date -lt $int_end_date ]]; do | ||
int_date_to=$(date -d"$int_start_date + 1 year" +"%Y%m%d") | ||
if [[ $int_date_to -ge $int_end_date ]]; then | ||
int_date_to="$int_end_date" | ||
fi | ||
date_from=$(date -d"$int_start_date" +"%Y-%m-%d") | ||
date_to=$(date -d"$int_date_to" +"%Y-%m-%d") | ||
python scheduler.py schedule-spider --spider_name="$spider" --start_date="$date_from" --end_date="$date_to" | ||
int_start_date="$int_date_to" | ||
done |
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