Advertisement
Sushill

lensoai api

Feb 5th, 2025 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. # pip install curl_cffi
  2. from curl_cffi import requests
  3.  
  4.  
  5. def extract_lensai(text):  
  6.     # Headers extracted from the original curl command
  7.     headers = {
  8.     "accept": "application/json, text/plain, */*",
  9.     "accept-encoding": "gzip, deflate, br, zstd",
  10.     "accept-language": "en-US,en;q=0.9,mr;q=0.8",
  11.     "cache-control": "no-cache",
  12.     "content-type": "application/json",
  13.     "cookie": "search_consent=true; facial_search_consent=true",
  14.     "origin": "https://lenso.ai",
  15.     "pragma": "no-cache",
  16.     "referer": "https://lenso.ai/en/search-by-text?desc=football&type=relatedText&page=1",
  17.     "sec-ch-ua": '"Not A(Brand";v="8", "Chromium";v="132", "Google Chrome";v="132"',
  18.     "sec-ch-ua-mobile": "?0",
  19.     "sec-ch-ua-platform": '"Windows"',
  20.     "sec-fetch-dest": "empty",
  21.     "sec-fetch-mode": "cors",
  22.     "sec-fetch-site": "same-origin",
  23.     "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36",
  24. }
  25.  
  26.  
  27.     payload = {
  28.     "desc": f"{text}",
  29.     "type": "relatedText",
  30.     "page": 1
  31. }
  32.     api_url = "https://lenso.ai/api/search/text"
  33.     cont = requests.post(api_url, impersonate='chrome', headers = headers, json = payload)
  34.     return cont.text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement