Skip to content

Instantly share code, notes, and snippets.

@bipinkrish
Created August 4, 2023 16:03
Show Gist options
  • Save bipinkrish/7d9bf3607187e7213e6dc494289dcf28 to your computer and use it in GitHub Desktop.
Save bipinkrish/7d9bf3607187e7213e6dc494289dcf28 to your computer and use it in GitHub Desktop.
PSA Scrape
import requests
from bs4 import BeautifulSoup
import time
import re
CF = "" # cf_clearance cookie value for the psa site from your browser
URL = "" # psa url, ex: https://psa.wf/movie/corner-office-2022/
SLEEP_TIME = 5 # do not change this
def try2link_bypass(url):
client = requests.session()
url = url[:-1] if url[-1] == '/' else url
params = (('d', int(time.time()) + (60 * 4)),)
r = client.get(url, params=params, headers= {'Referer': 'https://newforex.online/'})
soup = BeautifulSoup(r.text, 'html.parser')
inputs = soup.find(id="go-link").find_all(name="input")
data = { input.get('name'): input.get('value') for input in inputs }
time.sleep(SLEEP_TIME)
headers = {'Host': 'try2link.com', 'X-Requested-With': 'XMLHttpRequest', 'Origin': 'https://try2link.com', 'Referer': url}
bypassed_url = client.post('https://try2link.com/links/go', headers=headers,data=data)
return bypassed_url.json()["url"]
def try2link_scrape(url):
client = requests.session()
h = {'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',}
res = client.get(url, cookies={}, headers=h)
url = 'https://try2link.com/'+re.findall('try2link\.com\/(.*?) ', res.text)[0]
return try2link_bypass(url)
def psa_bypasser(psa_url):
cookies = {'cf_clearance': CF }
headers = {
'authority': 'psa.wf',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'en-US,en;q=0.9',
'referer': 'https://psa.wf/',
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36',
}
r = requests.get(psa_url, headers=headers, cookies=cookies)
soup = BeautifulSoup(r.text, "html.parser").find_all(class_="dropshadowboxes-drop-shadow dropshadowboxes-rounded-corners dropshadowboxes-inside-and-outside-shadow dropshadowboxes-lifted-both dropshadowboxes-effect-default")
links = []
for link in soup:
try:
exit_gate = link.a.get("href")
if "/exit" in exit_gate:
print("Passing :", exit_gate, end="\n\n")
links.append(try2link_scrape(exit_gate))
except: pass
print("\n")
finals = ""
for li in links:
print("Scrapping :", li, end="\n\n")
try:
res = requests.get(li, headers=headers, cookies=cookies)
soup = BeautifulSoup(res.text,"html.parser")
name = soup.find("h1",class_="entry-title", itemprop="headline").getText()
finals += name + "\n\n"
soup = soup.find("div", class_="entry-content" ,itemprop="text").findAll("a")
for ele in soup: finals += "○ " + ele.get("href") + "\n"
finals += "\n\n"
except: finals += "○ " + li + "\n\n"
return finals[:-1]
res = psa_bypasser(URL)
print("\n\n----------------------------------\n")
print(res)
print("----------------------------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment