Download holerite PDF using python at Portal do RH.
I no longer have access to Portal do RH, so I cannot follow maintaining this project anymore.
- E-mail with downloaded PDF attachment by Mail Gun
- Execution notification by Push Bullet
docker run -v $(pwd):/usr/workspace/downloads \
-e RH_USERNAME='YOUR USERNAME HERE' \
-e RH_PASSWORD='YOUR PASSWORD HERE' \
-e RH_SEARCH_YEAR='2018' \
-e RH_SEARCH_MONTH='03' \
viniciusgava/portaldorh-holerite-download:latest
The above command will save pdf in $(pwd)
, it means the directory where you run it.
File name is the search year + search month, YYYY-MM.pdf
.
example:
2018-03.pdf
Search Year
Required: Yes
Search Month
Required: Yes
Your username to login
Required: Yes
Your password to login
Required: Yes
Portal do RH URL
Required: No
Default: https://www.portaldorh.com.br/portal_rckt/auto_default.aspx
Where files will be saved.
Required: No
Default: /usr/workspace/downloads
All Required fields bellow are required only if MAIL_GUN_ENABLE
env setted as true
Integrate with mail gun? true or false
Required: No
Default: false
Mail Gun API Key
Required: Yes
Mail Gun Domain
Required: Yes
Mail origin
Required: Yes
Example:: Name name@mail.com
Mail destination
Required: Yes
Example:: Name name@mail.com
Mail subject
Required: Yes
Placeholder Available: Yes
Mail content as text
Required: Yes if MAIL_GUN_HTML
is not setted
Placeholder Available: Yes
Mail content as text
Required: Yes if MAIL_GUN_TEXT
is not setted
Placeholder Available: Yes
All Required fields bellow are required only if PUSH_BULLET_ENABLE
env setted as true
Integrate with push bullet? true or false
Required: No
Default: false
Push Bullet API Token
Required: Yes
Notification Title
Required: Yes
Placeholder Available: Yes
Notification Body
Required: Yes
Placeholder Available: Yes
Makefile and instruction bellow expected you uses python3.
- Clone repository
- Run
make prepare-local
- Edit
src/settings/local.py
file with your information. - Run
python3 src/app.py local
Some integration fields accept placeholder, that means you can use internal fields used on integration on your texts.
Fields that accept placeholders are marked on Env Variables of each integration.
%(placeholderName)s
Example:
This is my holerite at %(search_year)s/%(search_month)s
- search_year
- search_month
First create bash like this:
#!/bin/bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
# print current date at log
date
# GET LAST MONTH YEAR AND MONTH
LAST_MONTH_YEAR=$(date +'%Y' -d 'last month')
LAST_MONTH_MONTH=$(date +'%m' -d 'last month')
echo "search year: $LAST_MONTH_YEAR"
echo "search month: $LAST_MONTH_MONTH"
# try 5 times
n=0
until [ $n -ge 2 ]
do
echo "trying $n"
/usr/bin/docker run --env-file "$SCRIPTPATH/env-configs" \
-e RH_SEARCH_YEAR="$LAST_MONTH_YEAR" \
-e RH_SEARCH_MONTH="$LAST_MONTH_MONTH" \
--rm
viniciusgava/portaldorh-holerite-download:latest 2>&1 && break
n=$[$n+1]
sleep 15
done
Mac tip: You must to pass docker full path to works at crontab
/usr/local/bin/docker
Second add all env variables at env-configs
.
Example:
RH_USERNAME=YOUR USERNAME HERE
RH_PASSWORD=YOUR PASSWORD HERE
DO NOT use quotation to define values on env files.
Then run crontab -e
and add the follow cron.
Example:
0 8 7 * * sh /home/username/automate/holerite/run.sh >> /home/username/automate/holerite/log.log
The example bellow runs 8am of day 7 of every month.
You can generate a different crontab config on https://crontab-generator.org