Optimization.
[redakcja.git] / src / depot / woblink.py
1 import re
2 from django.conf import settings
3 import requests
4
5
6 def get_woblink_session(*args, **kwargs):
7     session = requests.Session()
8     response = session.get('https://publisher.woblink.com/login')
9     token = re.search(
10         r'name="_csrf_token" value="([^"]+)"',
11         response.text
12     ).group(1)
13     data = {
14         '_csrf_token': token,
15     }
16     data.update(settings.WOBLINK_CREDENTIALS)
17     response = session.post(
18         'https://publisher.woblink.com/login_check',
19         data=data,
20     )
21     return session
22
23
24