Added FlareSolverr fro 1337x

This commit is contained in:
Cedric
2024-01-29 09:15:46 -06:00
parent 85af1bb66d
commit 07d4d020e6
2 changed files with 14 additions and 2 deletions

View File

@@ -53,3 +53,8 @@ services:
volumes: volumes:
mongo-data: mongo-data:
postgres-data: postgres-data:
flaresolverr:
image: ghcr.io/flaresolverr/flaresolverr:latest
restart: unless-stopped
ports:
- 8191:8191

View File

@@ -83,9 +83,16 @@ function singleRequest(requestUrl, config = {}) {
const timeout = config.timeout || defaultTimeout; const timeout = config.timeout || defaultTimeout;
const options = { headers: { 'User-Agent': getRandomUserAgent() }, timeout: timeout }; const options = { headers: { 'User-Agent': getRandomUserAgent() }, timeout: timeout };
return axios.get(requestUrl, options) return axios.post('http://flaresolverr:8191/v1', {
cmd: 'request.get',
url: requestUrl,
}, options)
.then((response) => { .then((response) => {
const body = response.data; if (response.data.status !== 'ok'){
throw new Error(`FlareSolverr did not return status 'ok': ${response.data.message}`)
}
const body = response.data.solution.response;
if (!body) { if (!body) {
throw new Error(`No body: ${requestUrl}`); throw new Error(`No body: ${requestUrl}`);
} else if (body.includes('502: Bad gateway') || } else if (body.includes('502: Bad gateway') ||