-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_data_from_js_dynamic_site.py
42 lines (31 loc) · 1.08 KB
/
get_data_from_js_dynamic_site.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''
This is an example of getting data from dynamic js site with auth
You can also use this example to get data from API because it has the same algorithm
Look more documentation about how to take access to site API:
'''
def get_data_from_js_dynamic_site(login_url, email, password, header, main_link):
'''
:param login_url: url for auth api
:param email: your site login
:param password: your site password
:param header: user-agent in api
:param main_link: your main get request
:return: result of get request
'''
from requests_html import HTMLSession
headers = {
'user-agent': header
}
# you should check that there enough params to your login api
data = {
'email': email,
'password': password
}
session = HTMLSession()
session.headers.update(headers)
# login to our site
response = session.post(login_url, data=data)
result = session.get(main_link)
# you can work with result of this get request like as api
# example of json result result.json()['column']
return result