Regularly collects data from Yandex Direct. Stores this data in Google Spreadsheet.
Script uses:
- Yandex Direct API
- Gspread for authorization in Google SpreadSheets
-
Create Google SpreadSheet
-
In SpreadSheet:
- Create 2 tabs called 'hourly', 'daily'.
- Add headers in the first row: 'Date/Time', '', '', 'Google', 'Yandex'
- In the first column of 'daily' tab write yesterday's date, i.e. '08.01.18'
- In the first column of 'hourly' tab write today's date and time, i.e. '09.01 12:00'
-
Create project
git clone https://github.com/iakovleva/vu_yandex
cd vu_yandex
-
Get Google API credentials for Gspread authorize. Follow https://gspread.readthedocs.io/en/latest/oauth2.html Save JSON file with credentials in the current directory.
-
Add env variables to .env file
CRED_FILE - JSON file with Google API credentials TOKEN - Yandex OAuth-токен пользователя SPREADSHEET_INCOME - Google Spreadsheet URL
- Build image and run container
docker run --rm --env-file .env $(docker build -q .) hourly
docker run --rm --env-file .env $(docker build -q .) daily
Detailed by regions:
docker run --rm --env-file .env $(docker build -q .) hourly regions
docker run --rm --env-file .env $(docker build -q .) daily regions
- Optionally add cron job
* * * * * /usr/bin/docker run --env-file .env vu_income:yandex hourly > ~/vu_yandex/hourly.log