-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgplink.py
44 lines (35 loc) · 1.15 KB
/
gplink.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
43
44
# Kanged
"""
Credits to @Yuuki [github.com/xcscxr]
https://github.com/xcscxr/gplinks-bypass/blob/main/gplinks_bypass.py
"""
import asyncio
import cloudscraper
from urllib.parse import urlparse
from bs4 import BeautifulSoup
async def get_link(url: str):
client = cloudscraper.create_scraper(allow_brotli=False)
p = urlparse(url)
final_url = f'{p.scheme}://{p.netloc}/links/go'
res = client.head(url)
header_loc = res.headers['location']
param = header_loc.split('postid=')[-1]
req_url = f'{p.scheme}://{p.netloc}/{param}'
p = urlparse(header_loc)
ref_url = f'{p.scheme}://{p.netloc}/'
h = { 'referer': ref_url }
res = client.get(req_url, headers=h, allow_redirects=False)
bs4 = BeautifulSoup(res.content, 'html.parser')
inputs = bs4.find_all('input')
data = { input.get('name'): input.get('value') for input in inputs }
h = {
'referer': ref_url,
'x-requested-with': 'XMLHttpRequest',
}
asyncio.sleep(10)
res = client.post(final_url, headers=h, data=data)
try:
return res.json()['url'].replace('\/','/')
except Exception as e:
print(e)
return False