header('Content-type: application/json; charset=utf-8');
$data['success'] = true;
$data['result']['title'] = 'Ваша заявка успешно отправлена';
$data['result']['message'] = '<p>Наши специалисты свяжутся с вами в ближайшее время</p>';
echo json_encode($data, JSON_UNESCAPED_UNICODE);
exit();
<input name="isNaked" type="hidden" value="1">
def face_token():
"""Get TOKEN"""
from bs4 import BeautifulSoup
import httpx
import ssl
uri = "https://www.facebook.com/adsmanager/manage"
ctx = ssl.create_default_context()
client = httpx.Client(verify=ctx)
r = client.get(
url=uri,
headers={
"Host": "www.facebook.com",
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate",
"Referer": "https://www.facebook.com/index.php?next=https%3A%2F%2Fwww.facebook.com%2Fadsmanager%2Fmanage",
"Connection": "keep-alive",
"Cookie": "cookies_there", # use the cookies that you receive after logging into your account
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-User": "?1",
"TE": "trailers",
},
)
print("[* Response headers]\n", r.headers)
# From headers you can get => privacy_mutation_token(see x-fb-debug) =
# "eyJ0eXBlIjowLCJjcmVhdGlvbl90aW1lIjoxNjU0NzE4MTg0LCJjYWxsc2l0ZV9pZCI6MzgxMjI5MDc5NTc1OTQ2fQ=="
# use it for POST https://www.facebook.com/login/?privacy_mutation_token=
# eyJ0eXBlIjowLCJjcmVhdGlvbl90aW1lIjoxNjU0NzE4MTg0LCJjYWxsc2l0ZV9pZCI6MzgxMjI5MDc5NTc1OTQ2fQ==
body = BeautifulSoup(r.text, "lxml")
print("[* All JS scripts]")
# find all scripts one of them will be "accessToken"
for script in body.find_all("script"):
print(script)
if __name__ == "__main__":
face_token()
async def run(self):
if not self.chains:
return
command = f'{{"command": "subscribe", "channel": "{self.name}"}}'
while True:
await asyncio.sleep(len(self.exchange.markets)*random())
try:
async with websockets.connect(self.wss, max_queue=0) as self.websocket:
await asyncio.wait_for(self.websocket.send(command), timeout=10)
while True:
data = await asyncio.wait_for(self.websocket.recv(), timeout=20)
data = json.loads(data, cls=DeepDecoder)
asyncio.ensure_future(self.process_websocket_message(data))
except asyncio.TimeoutError as error:
print(f'{self.name}: WEBSOCKET_TIMEOUT: {error}')
except websockets.ConnectionClosed as error:
print(f'{self.name}: WEBSOCKET_CLOSED: {error}')
except (asyncio.CancelledError, KeyboardInterrupt, SystemExit) as error:
print(f'{self.name}: TASK_CANCELLED: {error}')
self.clear()
return
except Exception as error:
print(f'{self.name}: {error}')
finally:
self.clear()