https://github.com/korniichuk/requestium-automation-demo
Example of booking automation with Requestium Python library on https://bezkolejki.eu/suw
https://github.com/korniichuk/requestium-automation-demo
bezkolejki bezkolejki-eu python requestium requests selenium web-auto web-automation
Last synced: 7 months ago
JSON representation
Example of booking automation with Requestium Python library on https://bezkolejki.eu/suw
- Host: GitHub
- URL: https://github.com/korniichuk/requestium-automation-demo
- Owner: korniichuk
- License: unlicense
- Created: 2021-09-07T22:51:55.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-09-08T02:27:58.000Z (about 4 years ago)
- Last Synced: 2025-01-17T08:28:23.804Z (9 months ago)
- Topics: bezkolejki, bezkolejki-eu, python, requestium, requests, selenium, web-auto, web-automation
- Language: Python
- Homepage: http://www.korniichuk.com
- Size: 264 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# requestium-automation-demo
**Name:** requestium-automation-demo
**Description:** Example of booking automation with [Requestium](https://github.com/tryolabs/requestium) Python library on https://bezkolejki.eu/suw
**GitHub:** https://github.com/korniichuk/requestium-automation-demo
**Owner:** Ruslan Korniichuk## Table of Contents
* **[Portability](#portability)**
* **[How to run](#how-to-run)**
* **[Python script](#python-script)**
* **[FAQ](#faq)**## Portability
`requestium-automation-demo` checked on Ubuntu Desktop 18.04 LTS operating system.## How to run
### Python script
**Step 1:** Install operating system packages:
```sh
$ sudo apt update
$ sudo apt install google-chrome-stable
$ sudo apt install chromium-chromedriver
```**Step 2:** Create `var/log/booking` folder for logger:
```sh
$ sudo mkdir /var/log/booking
$ sudo chown $USER:$USER /var/log/booking
```**Step 3:** Install Python packages:
```sh
$ pip3 install --upgrade --user --requirement requirements.txt
```**Note:** You can install Python packages using virtual environments (recommended). Example:
```sh
$ pipenv --python 3.6
$ pipenv shell
$ pipenv install
```**Step 4:** Run Python script:
```sh
$ python3 booking_auto_example.py
```[](https://youtu.be/hroRpT8mq6M)
## FAQ
**1. How to get bezkolejki.eu security token:**
```python3
import requestsurl = 'https://bezkolejki.eu/api/Authentication/GetEmptyToken/suw'
r = requests.get(url)
token = r.json()['token']
print(f"token: '{token}'")
```**2. How to get recaptcha token:**
```python3
import reimport requests
recaptcha_regex = re.compile(r'')
k = '6LeCXbUUAAAAALp9bXMEorp7ONUX1cB1LwKoXeUY'
co = 'aHR0cHM6Ly9iZXprb2xlamtpLmV1OjQ0Mw..'
v = 'wxAi4AKLXL2kBAvXqI4XLSWS'
cb = '123456789' # TODO
url = f'https://www.google.com/recaptcha/api2/anchor?ar=1&k={k}&co={co}&hl=en&v={v}&size=invisible&cb={cb}'
r = requests.get(url)
recaptcha_token = recaptcha_regex.search(r.text).group(1)
print(f"recaptcha token: '{recaptcha_token}'")
```**3. How to get solved recaptcha token for bezkolejki.eu:**
```python3
import jsonimport requests
prefix = ")]}'"
k = '6LeCXbUUAAAAALp9bXMEorp7ONUX1cB1LwKoXeUY'
url = f'https://www.google.com/recaptcha/api2/reload?k={k}'
data = {"reason": "q", "c": recaptcha_token}
r = requests.post(url, data=data)
text = r.text
if text.startswith(prefix):
text = text[len(prefix):]
solved_recaptcha_token = json.loads(text)[1]
print(f"solved recaptcha token: {solved_recaptcha_token}")
```**4. How to get available dates:**
```python3
import requestsoperation_id = 95
url = f'https://bezkolejki.eu/api/Slot/GetAvailableDaysForOperation?operationId={operation_id}&recaptchaToken={solved_recaptcha_token}'
headers = {'Authorization': f'Bearer {token}'}
r = requests.get(url, headers=headers)
dates = r.json()
print(f'available dates: {dates}')
```