Remove FlareSolverr session management
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
068aebdaaf
commit
8dc0b49e18
@ -8,49 +8,27 @@ class FlareRequests(Session):
|
|||||||
if not CLOUDPROXY_ENDPOINT:
|
if not CLOUDPROXY_ENDPOINT:
|
||||||
return super().request(method, url, params, timeout=timeout, **kwargs)
|
return super().request(method, url, params, timeout=timeout, **kwargs)
|
||||||
|
|
||||||
sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json()
|
response = post(
|
||||||
|
CLOUDPROXY_ENDPOINT,
|
||||||
|
json={
|
||||||
|
"cmd": f"request.{method.lower()}",
|
||||||
|
"url": url,
|
||||||
|
"postData": parse.urlencode(params) if params else "",
|
||||||
|
"maxTimeout": timeout * 1000,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
solution = response.json()
|
||||||
|
|
||||||
if "sessions" in sessions and len(sessions["sessions"]) > 0:
|
if "solution" in solution:
|
||||||
FLARESESSION = sessions["sessions"][0]
|
resolved = Response()
|
||||||
else:
|
|
||||||
response = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.create"})
|
|
||||||
session = response.json()
|
|
||||||
|
|
||||||
if "session" in session:
|
resolved.raw = solution["solution"]["response"]
|
||||||
FLARESESSION = session["session"]
|
resolved.status_code = solution["solution"]["status"]
|
||||||
else:
|
resolved.headers = solution["solution"]["headers"]
|
||||||
raise RequestException(response)
|
resolved.url = url
|
||||||
|
resolved.reason = solution["status"]
|
||||||
|
resolved.cookies = solution["solution"]["cookies"]
|
||||||
|
|
||||||
try:
|
return resolved
|
||||||
response = post(
|
|
||||||
CLOUDPROXY_ENDPOINT,
|
|
||||||
json={
|
|
||||||
"cmd": f"request.{method.lower()}",
|
|
||||||
"session": FLARESESSION,
|
|
||||||
"url": url,
|
|
||||||
"postData": parse.urlencode(params) if params else "",
|
|
||||||
"maxTimeout": timeout * 1000,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
solution = response.json()
|
|
||||||
|
|
||||||
if "solution" in solution:
|
raise RequestException(response)
|
||||||
resolved = Response()
|
|
||||||
|
|
||||||
resolved.raw = solution["solution"]["response"]
|
|
||||||
resolved.status_code = solution["solution"]["status"]
|
|
||||||
resolved.headers = solution["solution"]["headers"]
|
|
||||||
resolved.url = url
|
|
||||||
resolved.reason = solution["status"]
|
|
||||||
resolved.cookies = solution["solution"]["cookies"]
|
|
||||||
|
|
||||||
return resolved
|
|
||||||
|
|
||||||
raise RequestException(response)
|
|
||||||
except RequestException:
|
|
||||||
session = post(
|
|
||||||
CLOUDPROXY_ENDPOINT,
|
|
||||||
json={"cmd": "sessions.destroy", "session": FLARESESSION},
|
|
||||||
)
|
|
||||||
|
|
||||||
raise RequestException(solution)
|
|
||||||
|
Reference in New Issue
Block a user