Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
taux1c
GitHub Repository: taux1c/onlyfans-scraper
Path: blob/main/onlyfans_scraper/api/me.py
961 views
1
r"""
2
_ __
3
___ _ __ | | _ _ / _| __ _ _ __ ___ ___ ___ _ __ __ _ _ __ ___ _ __
4
/ _ \ | '_ \ | || | | || |_ / _` || '_ \ / __| _____ / __| / __|| '__| / _` || '_ \ / _ \| '__|
5
| (_) || | | || || |_| || _|| (_| || | | |\__ \|_____|\__ \| (__ | | | (_| || |_) || __/| |
6
\___/ |_| |_||_| \__, ||_| \__,_||_| |_||___/ |___/ \___||_| \__,_|| .__/ \___||_|
7
|___/ |_|
8
"""
9
10
import httpx
11
12
from ..constants import meEP
13
from ..utils import auth, encoding
14
15
16
def scrape_user(headers):
17
with httpx.Client(http2=True, headers=headers) as c:
18
url = meEP
19
20
auth.add_cookies(c)
21
c.headers.update(auth.create_sign(url, headers))
22
23
r = c.get(url, timeout=None)
24
if not r.is_error:
25
return r.json()
26
r.raise_for_status()
27
28
29
def parse_user(profile):
30
name = encoding.encode_utf_16(profile['name'])
31
username = profile['username']
32
subscribe_count = profile['subscribesCount']
33
return (name, username, subscribe_count)
34
35
36
def print_user(name, username):
37
print(f'Welcome, {name} | {username}')
38
39