mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-12-05 17:18:19 +01:00
Compare commits
231 Commits
v2.0.0
...
drission-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eef473934 | ||
|
|
330e4f3a5e | ||
|
|
1c9222d8dd | ||
|
|
8f6c5a6391 | ||
|
|
8f5a223ed3 | ||
|
|
e847083479 | ||
|
|
ecad429269 | ||
|
|
4d97333160 | ||
|
|
37215107e9 | ||
|
|
af274a2485 | ||
|
|
eb680efc90 | ||
|
|
0f8f0bec25 | ||
|
|
3d9bc5627b | ||
|
|
dd7eaee2e3 | ||
|
|
031177bbdb | ||
|
|
a8644532a1 | ||
|
|
e96161c873 | ||
|
|
5a1f25cd52 | ||
|
|
a2c0e4348e | ||
|
|
2ecf88895b | ||
|
|
984368edb5 | ||
|
|
6c1d78cb84 | ||
|
|
5a2c61601e | ||
|
|
c304da2964 | ||
|
|
b811412699 | ||
|
|
0bb8de144f | ||
|
|
38166dfaa0 | ||
|
|
8dea0ed017 | ||
|
|
20cd2944a7 | ||
|
|
fd773e5909 | ||
|
|
35c7bff3c8 | ||
|
|
afdc1c7a8e | ||
|
|
0bc7a4498c | ||
|
|
c5a5f6d65e | ||
|
|
aaf29be8e1 | ||
|
|
800866d033 | ||
|
|
043f18b231 | ||
|
|
d21a332519 | ||
|
|
3ca6d08f41 | ||
|
|
227bd7ac72 | ||
|
|
e6a08584c0 | ||
|
|
df06d13cf8 | ||
|
|
993b8c41ac | ||
|
|
a4d42d7834 | ||
|
|
1c855b8af0 | ||
|
|
745c69491f | ||
|
|
f7e316fd5a | ||
|
|
16c8ab5f3d | ||
|
|
7af311b73c | ||
|
|
daec97532d | ||
|
|
8d7ed48f21 | ||
|
|
220f2599ae | ||
|
|
d772cf3f50 | ||
|
|
ab4365894b | ||
|
|
3fa9631559 | ||
|
|
04858c22fd | ||
|
|
5085ca6990 | ||
|
|
cd4df1e061 | ||
|
|
6c79783f7c | ||
|
|
4139e8d47c | ||
|
|
1942eb5fdc | ||
|
|
401bf5be76 | ||
|
|
d8ffdd3061 | ||
|
|
2d66590b08 | ||
|
|
a217510dc7 | ||
|
|
553bd8ab4f | ||
|
|
1b197c3e53 | ||
|
|
fd308f01be | ||
|
|
b5eef32615 | ||
|
|
644a843d89 | ||
|
|
82e1c94c6f | ||
|
|
fbc71516f5 | ||
|
|
40bd1cba4c | ||
|
|
d1588c1156 | ||
|
|
b4ad583baa | ||
|
|
5d31e551cc | ||
|
|
d92845f34f | ||
|
|
5d3b73ea9d | ||
|
|
2aa095ed5d | ||
|
|
687c8f75ae | ||
|
|
22ed3d324b | ||
|
|
5ba9ef03f3 | ||
|
|
d2e144ea12 | ||
|
|
313fb2c14b | ||
|
|
6d69f40b58 | ||
|
|
a1c36f60d2 | ||
|
|
0edc50e271 | ||
|
|
f4a4baa57c | ||
|
|
f7e434c6e3 | ||
|
|
7728f2ab31 | ||
|
|
c920bea4ca | ||
|
|
a785f83034 | ||
|
|
b42c22f5b1 | ||
|
|
9c62410a8b | ||
|
|
b8768ae17d | ||
|
|
9b2c602a1f | ||
|
|
8316350b98 | ||
|
|
33307ce461 | ||
|
|
cedb7bc54e | ||
|
|
6ecaf2362c | ||
|
|
3c97c9603a | ||
|
|
efaa5f31b6 | ||
|
|
4db85a2d0f | ||
|
|
66b9db21e5 | ||
|
|
ab0fe58d4a | ||
|
|
f68ddb7573 | ||
|
|
ac77110578 | ||
|
|
a9d1a2de2d | ||
|
|
ab5f14d6c3 | ||
|
|
e0bf02fb8b | ||
|
|
82a1cd835a | ||
|
|
7017715e21 | ||
|
|
ae18559db1 | ||
|
|
2680521008 | ||
|
|
2297bab185 | ||
|
|
8d9bac9dd4 | ||
|
|
30ccf18e85 | ||
|
|
a15d041a0c | ||
|
|
c6c74e7c9d | ||
|
|
49fd1aacfc | ||
|
|
f6879c70de | ||
|
|
24f59a39cb | ||
|
|
4d16105176 | ||
|
|
5957b7b3bc | ||
|
|
8de16058d0 | ||
|
|
5fc4f966a5 | ||
|
|
b903a5dd84 | ||
|
|
7e9d5f424f | ||
|
|
fc6d2d9095 | ||
|
|
aef9b2d4d6 | ||
|
|
6dc279a9d3 | ||
|
|
96fcd21174 | ||
|
|
3a6e8e0f92 | ||
|
|
2d97f88276 | ||
|
|
ac5c64319e | ||
|
|
c93834e2f0 | ||
|
|
e3b4200d94 | ||
|
|
0941861f80 | ||
|
|
8a10eb27a6 | ||
|
|
e9c08c84ef | ||
|
|
2aa1744476 | ||
|
|
a89679a52d | ||
|
|
410ee7981f | ||
|
|
e163019f28 | ||
|
|
7d84f1b663 | ||
|
|
4807e9dbe2 | ||
|
|
85360df336 | ||
|
|
fd42fcee66 | ||
|
|
90a831a13b | ||
|
|
904072267a | ||
|
|
f63816905b | ||
|
|
258225a091 | ||
|
|
da2263c85b | ||
|
|
70a423805d | ||
|
|
99d074084a | ||
|
|
c7251da54f | ||
|
|
676a930f02 | ||
|
|
ecaac2e1d9 | ||
|
|
60a22625be | ||
|
|
b32d7b70be | ||
|
|
f10f7269ca | ||
|
|
33bed9428e | ||
|
|
5092b1eef9 | ||
|
|
0cfcb57e3a | ||
|
|
59bd7c8bdd | ||
|
|
b90d263159 | ||
|
|
5257f47d34 | ||
|
|
613e49e6cb | ||
|
|
1505595591 | ||
|
|
8d1ac09bf2 | ||
|
|
31265a510d | ||
|
|
e967e135a3 | ||
|
|
383025032b | ||
|
|
345628e3e4 | ||
|
|
35c2f09202 | ||
|
|
197258e921 | ||
|
|
c99101f74b | ||
|
|
5703caa9d3 | ||
|
|
aa254eb830 | ||
|
|
436831edb8 | ||
|
|
b17a3a369b | ||
|
|
a74884d0c1 | ||
|
|
0e2452e40e | ||
|
|
ce52321b78 | ||
|
|
4e07ed0f6c | ||
|
|
9d607dcc8c | ||
|
|
a2345affb3 | ||
|
|
d79782bec9 | ||
|
|
1440e3c253 | ||
|
|
c5df58529a | ||
|
|
3ed7cc713e | ||
|
|
e505f906ea | ||
|
|
2fc9fdf3ae | ||
|
|
3f279e9aa9 | ||
|
|
d962e1a14e | ||
|
|
93d8350097 | ||
|
|
d34b43e0a8 | ||
|
|
2bf4dc62da | ||
|
|
bb0d757755 | ||
|
|
fc1fa601eb | ||
|
|
9b1f8332c7 | ||
|
|
6175fee75a | ||
|
|
bb4fa9cabc | ||
|
|
c951ba2523 | ||
|
|
6c598d5360 | ||
|
|
2893f72237 | ||
|
|
cd221bbbf1 | ||
|
|
68fb96f0d8 | ||
|
|
07724e598f | ||
|
|
56fc688517 | ||
|
|
0a438358d1 | ||
|
|
0cbca1fb79 | ||
|
|
05dcae979c | ||
|
|
fe6cfd75b8 | ||
|
|
bb7e82e6c4 | ||
|
|
fdd1d245f4 | ||
|
|
bc6ac68e52 | ||
|
|
a9ab2569bc | ||
|
|
b1a6ad7688 | ||
|
|
642d67b927 | ||
|
|
c4ef6a472e | ||
|
|
a24b665bd1 | ||
|
|
6576e1908d | ||
|
|
8e518d7267 | ||
|
|
3005ba3629 | ||
|
|
176c69d1e8 | ||
|
|
7a1cf7dd80 | ||
|
|
456dfc222e | ||
|
|
23fde49f2b | ||
|
|
78daf24bc3 | ||
|
|
47c83ded58 |
@@ -1,7 +1,5 @@
|
|||||||
.git/
|
.git/
|
||||||
.github/
|
.github/
|
||||||
.idea/
|
.idea/
|
||||||
bin/
|
html_samples/
|
||||||
dist/
|
|
||||||
node_modules/
|
|
||||||
resources/
|
resources/
|
||||||
|
|||||||
15
.eslintrc.js
15
.eslintrc.js
@@ -1,15 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
commonjs: true,
|
|
||||||
es2020: true
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
'standard'
|
|
||||||
],
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 11
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
32
.github/ISSUE_TEMPLATE.md
vendored
32
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,32 +0,0 @@
|
|||||||
**Please use the search bar** at the top of the page and make sure you are not creating an already submitted issue.
|
|
||||||
Check closed issues as well, because your issue may have already been fixed.
|
|
||||||
|
|
||||||
### How to enable debug and html traces
|
|
||||||
|
|
||||||
[Follow the instructions from this wiki page](https://github.com/FlareSolverr/FlareSolverr/wiki/How-to-enable-debug-and-html-trace)
|
|
||||||
|
|
||||||
### Environment
|
|
||||||
|
|
||||||
* **FlareSolverr version**:
|
|
||||||
* **Last working FlareSolverr version**:
|
|
||||||
* **Operating system**:
|
|
||||||
* **Are you using Docker**: [yes/no]
|
|
||||||
* **FlareSolverr User-Agent (see log traces or / endpoint)**:
|
|
||||||
* **Are you using a proxy or VPN?** [yes/no]
|
|
||||||
* **Are you using Captcha Solver:** [yes/no]
|
|
||||||
* **If using captcha solver, which one:**
|
|
||||||
* **URL to test this issue:**
|
|
||||||
|
|
||||||
### Description
|
|
||||||
|
|
||||||
[List steps to reproduce the error and details on what happens and what you expected to happen]
|
|
||||||
|
|
||||||
### Logged Error Messages
|
|
||||||
|
|
||||||
[Place any relevant error messages you noticed from the logs here.]
|
|
||||||
|
|
||||||
[Make sure you attach the full logs with your personal information removed in case we need more information]
|
|
||||||
|
|
||||||
### Screenshots
|
|
||||||
|
|
||||||
[Place any screenshots of the issue here if needed]
|
|
||||||
71
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
71
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
name: Bug report
|
||||||
|
description: Create a report of your issue
|
||||||
|
body:
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Have you checked our README?
|
||||||
|
description: Please check the <a href="https://github.com/FlareSolverr/FlareSolverr/blob/master/README.md">README</a>.
|
||||||
|
options:
|
||||||
|
- label: I have checked the README
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Have you followed our Troubleshooting?
|
||||||
|
description: Please follow our <a href="https://github.com/FlareSolverr/FlareSolverr/wiki/Troubleshooting">Troubleshooting</a>.
|
||||||
|
options:
|
||||||
|
- label: I have followed your Troubleshooting
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Is there already an issue for your problem?
|
||||||
|
description: Please make sure you are not creating an already submitted <a href="https://github.com/FlareSolverr/FlareSolverr/issues">Issue</a>. Check closed issues as well, because your issue may have already been fixed.
|
||||||
|
options:
|
||||||
|
- label: I have checked older issues, open and closed
|
||||||
|
required: true
|
||||||
|
- type: checkboxes
|
||||||
|
attributes:
|
||||||
|
label: Have you checked the discussions?
|
||||||
|
description: Please read our <a href="https://github.com/FlareSolverr/FlareSolverr/discussions">Discussions</a> before submitting your issue, some wider problems may be dealt with there.
|
||||||
|
options:
|
||||||
|
- label: I have read the Discussions
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Environment
|
||||||
|
description: Please provide the details of the system FlareSolverr is running on.
|
||||||
|
value: |
|
||||||
|
- FlareSolverr version:
|
||||||
|
- Last working FlareSolverr version:
|
||||||
|
- Operating system:
|
||||||
|
- Are you using Docker: [yes/no]
|
||||||
|
- FlareSolverr User-Agent (see log traces or / endpoint):
|
||||||
|
- Are you using a VPN: [yes/no]
|
||||||
|
- Are you using a Proxy: [yes/no]
|
||||||
|
- Are you using Captcha Solver: [yes/no]
|
||||||
|
- If using captcha solver, which one:
|
||||||
|
- URL to test this issue:
|
||||||
|
render: markdown
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: List steps to reproduce the error and details on what happens and what you expected to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Logged Error Messages
|
||||||
|
description: |
|
||||||
|
Place any relevant error messages you noticed from the logs here.
|
||||||
|
Make sure you attach the full logs with your personal information removed in case we need more information.
|
||||||
|
If you wish to provide debug logs, follow the instructions from this <a href="https://github.com/FlareSolverr/FlareSolverr/wiki/How-to-enable-debug-and-html-trace">wiki page</a>.
|
||||||
|
render: text
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Screenshots
|
||||||
|
description: Place any screenshots of the issue here if needed
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Requesting new features or changes
|
||||||
|
url: https://github.com/FlareSolverr/FlareSolverr/discussions
|
||||||
|
about: Please create a new discussion topic, grouped under "Ideas".
|
||||||
|
- name: Asking questions
|
||||||
|
url: https://github.com/FlareSolverr/FlareSolverr/discussions
|
||||||
|
about: Please create a new discussion topic, grouped under "Q&A".
|
||||||
4
.github/workflows/autotag.yml
vendored
4
.github/workflows/autotag.yml
vendored
@@ -6,12 +6,12 @@ on:
|
|||||||
- "master"
|
- "master"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
tag-release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
-
|
-
|
||||||
name: Auto Tag
|
name: Auto Tag
|
||||||
uses: Klemensas/action-autotag@stable
|
uses: Klemensas/action-autotag@stable
|
||||||
|
|||||||
72
.github/workflows/release-docker.yml
vendored
72
.github/workflows/release-docker.yml
vendored
@@ -4,50 +4,64 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-docker-images:
|
||||||
runs-on: ubuntu-latest
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
-
|
- name: Checkout
|
||||||
name: Checkout
|
uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v2
|
|
||||||
-
|
- name: Downcase repo
|
||||||
name: Downcase repo
|
|
||||||
run: echo REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
run: echo REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
|
||||||
-
|
|
||||||
name: Docker meta
|
- name: Docker meta
|
||||||
id: docker_meta
|
id: docker_meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REPOSITORY }},ghcr.io/${{ env.REPOSITORY }}
|
images: |
|
||||||
tag-sha: false
|
${{ env.REPOSITORY }},enable=${{ github.event_name != 'pull_request' }}
|
||||||
-
|
ghcr.io/${{ env.REPOSITORY }}
|
||||||
name: Set up QEMU
|
tags: |
|
||||||
uses: docker/setup-qemu-action@v1.0.1
|
type=semver,pattern={{version}},prefix=v
|
||||||
-
|
type=ref,event=pr
|
||||||
name: Set up Docker Buildx
|
flavor: |
|
||||||
uses: docker/setup-buildx-action@v1
|
latest=auto
|
||||||
-
|
|
||||||
name: Login to DockerHub
|
- name: Set up QEMU
|
||||||
uses: docker/login-action@v1
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GH_PAT }}
|
password: ${{ secrets.GH_PAT }}
|
||||||
-
|
|
||||||
name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||||
|
|||||||
72
.github/workflows/release.yml
vendored
72
.github/workflows/release.yml
vendored
@@ -6,26 +6,15 @@ on:
|
|||||||
- 'v*.*.*'
|
- 'v*.*.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
create-release:
|
||||||
name: Create release
|
name: Create release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # get all commits, branches and tags (required for the changelog)
|
fetch-depth: 0 # get all commits, branches and tags (required for the changelog)
|
||||||
|
|
||||||
- name: Setup Node
|
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '14'
|
|
||||||
|
|
||||||
- name: Build artifacts
|
|
||||||
run: |
|
|
||||||
npm install
|
|
||||||
npm run build
|
|
||||||
npm run package
|
|
||||||
|
|
||||||
- name: Build changelog
|
- name: Build changelog
|
||||||
id: github_changelog
|
id: github_changelog
|
||||||
run: |
|
run: |
|
||||||
@@ -47,9 +36,60 @@ jobs:
|
|||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
|
build-linux-package:
|
||||||
|
name: Build Linux binary
|
||||||
|
needs: create-release
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # get all commits, branches and tags (required for the changelog)
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Build artifacts
|
||||||
|
run: |
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
python -m pip install pyinstaller==5.13.0
|
||||||
|
cd src
|
||||||
|
python build_package.py
|
||||||
|
|
||||||
- name: Upload release artifacts
|
- name: Upload release artifacts
|
||||||
uses: alexellis/upload-assets@0.2.2
|
uses: alexellis/upload-assets@0.4.0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
with:
|
with:
|
||||||
asset_paths: '["./bin/*.zip"]'
|
asset_paths: '["./dist/flaresolverr_*"]'
|
||||||
|
|
||||||
|
build-windows-package:
|
||||||
|
name: Build Windows binary
|
||||||
|
needs: create-release
|
||||||
|
runs-on: windows-2022
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # get all commits, branches and tags (required for the changelog)
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Build artifacts
|
||||||
|
run: |
|
||||||
|
python -m pip install -r requirements.txt
|
||||||
|
python -m pip install pyinstaller==5.13.0
|
||||||
|
cd src
|
||||||
|
python build_package.py
|
||||||
|
|
||||||
|
- name: Upload release artifacts
|
||||||
|
uses: alexellis/upload-assets@0.4.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
with:
|
||||||
|
asset_paths: '["./dist/flaresolverr_*"]'
|
||||||
|
|||||||
249
.gitignore
vendored
249
.gitignore
vendored
@@ -1,126 +1,129 @@
|
|||||||
# Logs
|
# Editors
|
||||||
logs
|
.vscode/
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
|
||||||
web_modules/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
.parcel-cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
out
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
|
||||||
.vscode-test
|
|
||||||
|
|
||||||
# yarn v2
|
|
||||||
.yarn/cache
|
|
||||||
.yarn/unplugged
|
|
||||||
.yarn/build-state.yml
|
|
||||||
.yarn/install-state.gz
|
|
||||||
.pnp.*
|
|
||||||
|
|
||||||
# IntelliJ IDEA
|
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
|
||||||
|
|
||||||
# Project Development
|
# Vagrant
|
||||||
testing/
|
.vagrant/
|
||||||
|
|
||||||
# Binaries
|
# Mac/OSX
|
||||||
bin/
|
.DS_Store
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
dist_chrome/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# node
|
||||||
|
node_modules/
|
||||||
422
CHANGELOG.md
Normal file
422
CHANGELOG.md
Normal file
@@ -0,0 +1,422 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## v3.3.21 (2024/06/26)
|
||||||
|
* Add challenge selector to catch reloading page on non-English systems
|
||||||
|
* Escape values for generated form used in request.post. Thanks @mynameisbogdan
|
||||||
|
|
||||||
|
## v3.3.20 (2024/06/21)
|
||||||
|
* maxTimeout should always be int
|
||||||
|
* Check not running in Docker before logging version_main error
|
||||||
|
* Update Cloudflare challenge and checkbox selectors. Thanks @tenettow & @21hsmw
|
||||||
|
|
||||||
|
## v3.3.19 (2024/05/23)
|
||||||
|
* Fix occasional headless issue on Linux when set to "false". Thanks @21hsmw
|
||||||
|
|
||||||
|
## v3.3.18 (2024/05/20)
|
||||||
|
|
||||||
|
* Fix LANG ENV for Linux
|
||||||
|
* Fix Chrome v124+ not closing on Windows. Thanks @RileyXX
|
||||||
|
|
||||||
|
## v3.3.17 (2024/04/09)
|
||||||
|
|
||||||
|
* Fix file descriptor leak in service on quit(). Thanks @zkulis
|
||||||
|
|
||||||
|
## v3.3.16 (2024/02/28)
|
||||||
|
|
||||||
|
* Fix of the subprocess.STARTUPINFO() call. Thanks @ceconelo
|
||||||
|
* Add FreeBSD support. Thanks @Asthowen
|
||||||
|
* Use headless configuration properly. Thanks @hashworks
|
||||||
|
|
||||||
|
## v3.3.15 (2024/02/20)
|
||||||
|
|
||||||
|
* Fix looping challenges
|
||||||
|
|
||||||
|
## v3.3.14-hotfix2 (2024/02/17)
|
||||||
|
|
||||||
|
* Hotfix 2 - bad Chromium build, instances failed to terminate
|
||||||
|
|
||||||
|
## v3.3.14-hotfix (2024/02/17)
|
||||||
|
|
||||||
|
* Hotfix for Linux build - some Chrome files no longer exist
|
||||||
|
|
||||||
|
## v3.3.14 (2024/02/17)
|
||||||
|
|
||||||
|
* Update Chrome downloads. Thanks @opemvbs
|
||||||
|
|
||||||
|
## v3.3.13 (2024/01/07)
|
||||||
|
|
||||||
|
* Fix too many open files error
|
||||||
|
|
||||||
|
## v3.3.12 (2023/12/15)
|
||||||
|
|
||||||
|
* Fix looping challenges and invalid cookies
|
||||||
|
|
||||||
|
## v3.3.11 (2023/12/11)
|
||||||
|
|
||||||
|
* Update UC 3.5.4 & Selenium 4.15.2. Thanks @txtsd
|
||||||
|
|
||||||
|
## v3.3.10 (2023/11/14)
|
||||||
|
|
||||||
|
* Add LANG ENV - resolves issues with YGGtorrent
|
||||||
|
|
||||||
|
## v3.3.9 (2023/11/13)
|
||||||
|
|
||||||
|
* Fix for Docker build, capture TypeError
|
||||||
|
|
||||||
|
## v3.3.8 (2023/11/13)
|
||||||
|
|
||||||
|
* Fix headless=true for Chrome 117+. Thanks @NabiKAZ
|
||||||
|
* Support running Chrome 119 from source. Thanks @koleg and @Chris7X
|
||||||
|
* Fix "OSError: [WinError 6] The handle is invalid" on exit. Thanks @enesgorkemgenc
|
||||||
|
|
||||||
|
## v3.3.7 (2023/11/05)
|
||||||
|
|
||||||
|
* Bump to rebuild. Thanks @JoachimDorchies
|
||||||
|
|
||||||
|
## v3.3.6 (2023/09/15)
|
||||||
|
|
||||||
|
* Update checkbox selector, again
|
||||||
|
|
||||||
|
## v3.3.5 (2023/09/13)
|
||||||
|
|
||||||
|
* Change checkbox selector, support languages other than English
|
||||||
|
|
||||||
|
## v3.3.4 (2023/09/02)
|
||||||
|
|
||||||
|
* Update checkbox selector
|
||||||
|
|
||||||
|
## v3.3.3 (2023/08/31)
|
||||||
|
|
||||||
|
* Update undetected_chromedriver to v3.5.3
|
||||||
|
|
||||||
|
## v3.3.2 (2023/08/03)
|
||||||
|
|
||||||
|
* Fix URL domain in Prometheus exporter
|
||||||
|
|
||||||
|
## v3.3.1 (2023/08/03)
|
||||||
|
|
||||||
|
* Fix for Cloudflare verify checkbox
|
||||||
|
* Fix HEADLESS=false in Windows binary
|
||||||
|
* Fix Prometheus exporter for management and health endpoints
|
||||||
|
* Remove misleading stack trace when the verify checkbox is not found
|
||||||
|
* Revert "Update base Docker image to Debian Bookworm" #849
|
||||||
|
* Revert "Install Chromium 115 from Debian testing" #849
|
||||||
|
|
||||||
|
## v3.3.0 (2023/08/02)
|
||||||
|
|
||||||
|
* Fix for new Cloudflare detection. Thanks @cedric-bour for #845
|
||||||
|
* Add support for proxy authentication username/password. Thanks @jacobprice808 for #807
|
||||||
|
* Implement Prometheus metrics
|
||||||
|
* Fix Chromium Driver for Chrome / Chromium version > 114
|
||||||
|
* Use Chromium 115 in binary packages (Windows and Linux)
|
||||||
|
* Install Chromium 115 from Debian testing (Docker)
|
||||||
|
* Update base Docker image to Debian Bookworm
|
||||||
|
* Update Selenium 4.11.2
|
||||||
|
* Update pyinstaller 5.13.0
|
||||||
|
* Add more traces in build_package.py
|
||||||
|
|
||||||
|
## v3.2.2 (2023/07/16)
|
||||||
|
|
||||||
|
* Workaround for updated 'verify you are human' check
|
||||||
|
|
||||||
|
## v3.2.1 (2023/06/10)
|
||||||
|
|
||||||
|
* Kill dead Chrome processes in Windows
|
||||||
|
* Fix Chrome GL erros in ASUSTOR NAS
|
||||||
|
|
||||||
|
## v3.2.0 (2023/05/23)
|
||||||
|
|
||||||
|
* Support "proxy" param in requests and sessions
|
||||||
|
* Support "cookies" param in requests
|
||||||
|
* Fix Chromium exec permissions in Linux package
|
||||||
|
* Update Python dependencies
|
||||||
|
|
||||||
|
## v3.1.2 (2023/04/02)
|
||||||
|
|
||||||
|
* Fix headless mode in macOS
|
||||||
|
* Remove redundant artifact from Windows binary package
|
||||||
|
* Bump Selenium dependency
|
||||||
|
|
||||||
|
## v3.1.1 (2023/03/25)
|
||||||
|
|
||||||
|
* Distribute binary executables in compressed package
|
||||||
|
* Add icon for binary executable
|
||||||
|
* Include information about supported architectures in the readme
|
||||||
|
* Check Python version on start
|
||||||
|
|
||||||
|
## v3.1.0 (2023/03/20)
|
||||||
|
|
||||||
|
* Build binaries for Linux x64 and Windows x64
|
||||||
|
* Sessions with auto-creation on fetch request and TTL
|
||||||
|
* Fix error trace: Crash Reports/pending No such file or directory
|
||||||
|
* Fix Waitress server error with asyncore_use_poll=true
|
||||||
|
* Attempt to fix Docker ARM32 build
|
||||||
|
* Print platform information on start up
|
||||||
|
* Add Fairlane challenge selector
|
||||||
|
* Update DDOS-GUARD title
|
||||||
|
* Update dependencies
|
||||||
|
|
||||||
|
## v3.0.4 (2023/03/07)
|
||||||
|
|
||||||
|
* Click on the Cloudflare's 'Verify you are human' button if necessary
|
||||||
|
|
||||||
|
## v3.0.3 (2023/03/06)
|
||||||
|
|
||||||
|
* Update undetected_chromedriver version to 3.4.6
|
||||||
|
|
||||||
|
## v3.0.2 (2023/01/08)
|
||||||
|
|
||||||
|
* Detect Cloudflare blocked access
|
||||||
|
* Check Chrome / Chromium web browser is installed correctly
|
||||||
|
|
||||||
|
## v3.0.1 (2023/01/06)
|
||||||
|
|
||||||
|
* Kill Chromium processes properly to avoid defunct/zombie processes
|
||||||
|
* Update undetected-chromedriver
|
||||||
|
* Disable Zygote sandbox in Chromium browser
|
||||||
|
* Add more selectors to detect blocked access
|
||||||
|
* Include procps (ps), curl and vim packages in the Docker image
|
||||||
|
|
||||||
|
## v3.0.0 (2023/01/04)
|
||||||
|
|
||||||
|
* This is the first release of FlareSolverr v3. There are some breaking changes
|
||||||
|
* Docker images for linux/386, linux/amd64, linux/arm/v7 and linux/arm64/v8
|
||||||
|
* Replaced Firefox with Chrome
|
||||||
|
* Replaced NodeJS / Typescript with Python
|
||||||
|
* Replaced Puppeter with Selenium
|
||||||
|
* No binaries for Linux / Windows. You have to use the Docker image or install from Source code
|
||||||
|
* No proxy support
|
||||||
|
* No session support
|
||||||
|
|
||||||
|
## v2.2.10 (2022/10/22)
|
||||||
|
|
||||||
|
* Detect DDoS-Guard through title content
|
||||||
|
|
||||||
|
## v2.2.9 (2022/09/25)
|
||||||
|
|
||||||
|
* Detect Cloudflare Access Denied
|
||||||
|
* Commit the complete changelog
|
||||||
|
|
||||||
|
## v2.2.8 (2022/09/17)
|
||||||
|
|
||||||
|
* Remove 30 s delay and clean legacy code
|
||||||
|
|
||||||
|
## v2.2.7 (2022/09/12)
|
||||||
|
|
||||||
|
* Temporary fix: add 30s delay
|
||||||
|
* Update README.md
|
||||||
|
|
||||||
|
## v2.2.6 (2022/07/31)
|
||||||
|
|
||||||
|
* Fix Cloudflare detection in POST requests
|
||||||
|
|
||||||
|
## v2.2.5 (2022/07/30)
|
||||||
|
|
||||||
|
* Update GitHub actions to build executables with NodeJs 16
|
||||||
|
* Update Cloudflare selectors and add HTML samples
|
||||||
|
* Install Firefox 94 instead of the latest Nightly
|
||||||
|
* Update dependencies
|
||||||
|
* Upgrade Puppeteer (#396)
|
||||||
|
|
||||||
|
## v2.2.4 (2022/04/17)
|
||||||
|
|
||||||
|
* Detect DDoS-Guard challenge
|
||||||
|
|
||||||
|
## v2.2.3 (2022/04/16)
|
||||||
|
|
||||||
|
* Fix 2000 ms navigation timeout
|
||||||
|
* Update README.md (libseccomp2 package in Debian)
|
||||||
|
* Update README.md (clarify proxy parameter) (#307)
|
||||||
|
* Update NPM dependencies
|
||||||
|
* Disable Cloudflare ban detection
|
||||||
|
|
||||||
|
## v2.2.2 (2022/03/19)
|
||||||
|
|
||||||
|
* Fix ban detection. Resolves #330 (#336)
|
||||||
|
|
||||||
|
## v2.2.1 (2022/02/06)
|
||||||
|
|
||||||
|
* Fix max timeout error in some pages
|
||||||
|
* Avoid crashing in NodeJS 17 due to Unhandled promise rejection
|
||||||
|
* Improve proxy validation and debug traces
|
||||||
|
* Remove @types/puppeteer dependency
|
||||||
|
|
||||||
|
## v2.2.0 (2022/01/31)
|
||||||
|
|
||||||
|
* Increase default BROWSER_TIMEOUT=40000 (40 seconds)
|
||||||
|
* Fix Puppeter deprecation warnings
|
||||||
|
* Update base Docker image Alpine 3.15 / NodeJS 16
|
||||||
|
* Build precompiled binaries with NodeJS 16
|
||||||
|
* Update Puppeter and other dependencies
|
||||||
|
* Add support for Custom CloudFlare challenge
|
||||||
|
* Add support for DDoS-GUARD challenge
|
||||||
|
|
||||||
|
## v2.1.0 (2021/12/12)
|
||||||
|
|
||||||
|
* Add aarch64 to user agents to be replaced (#248)
|
||||||
|
* Fix SOCKSv4 and SOCKSv5 proxy. resolves #214 #220
|
||||||
|
* Remove redundant JSON key (postData) (#242)
|
||||||
|
* Make test URL configurable with TEST_URL env var. resolves #240
|
||||||
|
* Bypass new Cloudflare protection
|
||||||
|
* Update donation links
|
||||||
|
|
||||||
|
## v2.0.2 (2021/10/31)
|
||||||
|
|
||||||
|
* Fix SOCKS5 proxy. Resolves #214
|
||||||
|
* Replace Firefox ERS with a newer version
|
||||||
|
* Catch startup exceptions and give some advices
|
||||||
|
* Add env var BROWSER_TIMEOUT for slow systems
|
||||||
|
* Fix NPM warning in Docker images
|
||||||
|
|
||||||
|
## v2.0.1 (2021/10/24)
|
||||||
|
|
||||||
|
* Check user home dir before testing web browser installation
|
||||||
|
|
||||||
|
## v2.0.0 (2021/10/20)
|
||||||
|
|
||||||
|
FlareSolverr 2.0.0 is out with some important changes:
|
||||||
|
|
||||||
|
* It is capable of solving the automatic challenges of Cloudflare. CAPTCHAs (hCaptcha) cannot be resolved and the old solvers have been removed.
|
||||||
|
* The Chrome browser has been replaced by Firefox. This has caused some functionality to be removed. Parameters: `userAgent`, `headers`, `rawHtml` and `downloadare` no longer available.
|
||||||
|
* Included `proxy` support without user/password credentials. If you are writing your own integration with FlareSolverr, make sure your client uses the same User-Agent header and Proxy that FlareSolverr uses. Those values together with the Cookie are checked and detected by Cloudflare.
|
||||||
|
* FlareSolverr has been rewritten from scratch. From now on it should be easier to maintain and test.
|
||||||
|
* If you are using Jackett make sure you have version v0.18.1041 or higher. FlareSolverSharp v2.0.0 is out too.
|
||||||
|
|
||||||
|
Complete changelog:
|
||||||
|
|
||||||
|
* Bump version 2.0.0
|
||||||
|
* Set puppeteer timeout half of maxTimeout param. Resolves #180
|
||||||
|
* Add test for blocked IP
|
||||||
|
* Avoid reloading the page in case of error
|
||||||
|
* Improve Cloudflare detection
|
||||||
|
* Fix version
|
||||||
|
* Fix browser preferences and proxy
|
||||||
|
* Fix request.post method and clean error traces
|
||||||
|
* Use Firefox ESR for Docker images
|
||||||
|
* Improve Firefox start time and code clean up
|
||||||
|
* Improve bad request management and tests
|
||||||
|
* Build native packages with Firefox
|
||||||
|
* Update readme
|
||||||
|
* Improve Docker image and clean TODOs
|
||||||
|
* Add proxy support
|
||||||
|
* Implement request.post method for Firefox
|
||||||
|
* Code clean up, remove returnRawHtml, download, headers params
|
||||||
|
* Remove outdated chaptcha solvers
|
||||||
|
* Refactor the app to use Express server and Jest for tests
|
||||||
|
* Fix Cloudflare resolver for Linux ARM builds
|
||||||
|
* Fix Cloudflare resolver
|
||||||
|
* Replace Chrome web browser with Firefox
|
||||||
|
* Remove userAgent parameter since any modification is detected by CF
|
||||||
|
* Update dependencies
|
||||||
|
* Remove Puppeter steath plugin
|
||||||
|
|
||||||
|
## v1.2.9 (2021/08/01)
|
||||||
|
|
||||||
|
* Improve "Execution context was destroyed" error handling
|
||||||
|
* Implement returnRawHtml parameter. resolves #172 resolves #165
|
||||||
|
* Capture Docker stop signal. resolves #158
|
||||||
|
* Reduce Docker image size 20 MB
|
||||||
|
* Fix page reload after challenge is solved. resolves #162 resolves #143
|
||||||
|
* Avoid loading images/css/fonts to speed up page load
|
||||||
|
* Improve Cloudflare IP ban detection
|
||||||
|
* Fix vulnerabilities
|
||||||
|
|
||||||
|
## v1.2.8 (2021/06/01)
|
||||||
|
|
||||||
|
* Improve old JS challenge waiting. Resolves #129
|
||||||
|
|
||||||
|
## v1.2.7 (2021/06/01)
|
||||||
|
|
||||||
|
* Improvements in Cloudflare redirect detection. Resolves #140
|
||||||
|
* Fix installation instructions
|
||||||
|
|
||||||
|
## v1.2.6 (2021/05/30)
|
||||||
|
|
||||||
|
* Handle new Cloudflare challenge. Resolves #135 Resolves #134
|
||||||
|
* Provide reference Systemd unit file. Resolves #72
|
||||||
|
* Fix EACCES: permission denied, open '/tmp/flaresolverr.txt'. Resolves #120
|
||||||
|
* Configure timezone with TZ env var. Resolves #109
|
||||||
|
* Return the redirected URL in the response (#126)
|
||||||
|
* Show an error in hcaptcha-solver. Resolves #132
|
||||||
|
* Regenerate package-lock.json lockfileVersion 2
|
||||||
|
* Update issue template. Resolves #130
|
||||||
|
* Bump ws from 7.4.1 to 7.4.6 (#137)
|
||||||
|
* Bump hosted-git-info from 2.8.8 to 2.8.9 (#124)
|
||||||
|
* Bump lodash from 4.17.20 to 4.17.21 (#125)
|
||||||
|
|
||||||
|
## v1.2.5 (2021/04/05)
|
||||||
|
|
||||||
|
* Fix memory regression, close test browser
|
||||||
|
* Fix release-docker GitHub action
|
||||||
|
|
||||||
|
## v1.2.4 (2021/04/04)
|
||||||
|
|
||||||
|
* Include license in release zips. resolves #75
|
||||||
|
* Validate Chrome is working at startup
|
||||||
|
* Speedup Docker image build
|
||||||
|
* Add health check endpoint
|
||||||
|
* Update issue template
|
||||||
|
* Minor improvements in debug traces
|
||||||
|
* Validate environment variables at startup. resolves #101
|
||||||
|
* Add FlareSolverr logo. resolves #23
|
||||||
|
|
||||||
|
## v1.2.3 (2021/01/10)
|
||||||
|
|
||||||
|
* CI/CD: Generate release changelog from commits. resolves #34
|
||||||
|
* Update README.md
|
||||||
|
* Add donation links
|
||||||
|
* Simplify docker-compose.yml
|
||||||
|
* Allow to configure "none" captcha resolver
|
||||||
|
* Override docker-compose.yml variables via .env resolves #64 (#66)
|
||||||
|
|
||||||
|
## v1.2.2 (2021/01/09)
|
||||||
|
|
||||||
|
* Add documentation for precompiled binaries installation
|
||||||
|
* Add instructions to set environment variables in Windows
|
||||||
|
* Build Windows and Linux binaries. resolves #18
|
||||||
|
* Add release badge in the readme
|
||||||
|
* CI/CD: Generate release changelog from commits. resolves #34
|
||||||
|
* Add a notice about captcha solvers
|
||||||
|
* Add Chrome flag --disable-dev-shm-usage to fix crashes. resolves #45
|
||||||
|
* Fix Docker CLI documentation
|
||||||
|
* Add traces with captcha solver service. resolves #39
|
||||||
|
* Improve logic to detect Cloudflare captcha. resolves #48
|
||||||
|
* Move Cloudflare provider logic to his own class
|
||||||
|
* Simplify and document the "return only cookies" parameter
|
||||||
|
* Show message when debug log is enabled
|
||||||
|
* Update readme to add more clarifications. resolves #53 (#60)
|
||||||
|
* issue_template: typo fix (#52)
|
||||||
|
|
||||||
|
## v1.2.1 (2020/12/20)
|
||||||
|
|
||||||
|
* Change version to match release tag / 1.2.0 => v1.2.0
|
||||||
|
* CI/CD Publish release in GitHub repository. resolves #34
|
||||||
|
* Add welcome message in / endpoint
|
||||||
|
* Rewrite request timeout handling (maxTimeout) resolves #42
|
||||||
|
* Add http status for better logging
|
||||||
|
* Return an error when no selectors are found, #25
|
||||||
|
* Add issue template, fix #32
|
||||||
|
* Moving log.html right after loading the page and add one on reload, fix #30
|
||||||
|
* Update User-Agent to match chromium version, ref: #15 (#28)
|
||||||
|
* Update install from source code documentation
|
||||||
|
* Update readme to add Docker instructions (#20)
|
||||||
|
* Clean up readme (#19)
|
||||||
|
* Add docker-compose
|
||||||
|
* Change default log level to info
|
||||||
|
|
||||||
|
## v1.2.0 (2020/12/20)
|
||||||
|
|
||||||
|
* Fix User-Agent detected by CouldFlare (Docker ARM) resolves #15
|
||||||
|
* Include exception message in error response
|
||||||
|
* CI/CD: Rename GitHub Action build => publish
|
||||||
|
* Bump version
|
||||||
|
* Fix TypeScript compilation and bump minor version
|
||||||
|
* CI/CD: Bump minor version
|
||||||
|
* CI/CD: Configure GitHub Actions
|
||||||
|
* CI/CD: Configure GitHub Actions
|
||||||
|
* CI/CD: Bump minor version
|
||||||
|
* CI/CD: Configure Build GitHub Action
|
||||||
|
* CI/CD: Configure AutoTag GitHub Action (#14)
|
||||||
|
* CI/CD: Build the Docker images with GitHub Actions (#13)
|
||||||
|
* Update dependencies
|
||||||
|
* Backport changes from Cloudproxy (#11)
|
||||||
98
Dockerfile
98
Dockerfile
@@ -1,34 +1,78 @@
|
|||||||
FROM --platform=${TARGETPLATFORM:-linux/amd64} node:16-alpine3.14
|
FROM python:3.11-slim-bullseye as builder
|
||||||
|
|
||||||
# Print build information
|
# Build dummy packages to skip installing them and their dependencies
|
||||||
ARG TARGETPLATFORM
|
RUN apt-get update \
|
||||||
ARG BUILDPLATFORM
|
&& apt-get install -y --no-install-recommends equivs \
|
||||||
RUN printf "I am running on ${BUILDPLATFORM:-linux/amd64}, building for ${TARGETPLATFORM:-linux/amd64}\n$(uname -a)\n"
|
&& equivs-control libgl1-mesa-dri \
|
||||||
|
&& printf 'Section: misc\nPriority: optional\nStandards-Version: 3.9.2\nPackage: libgl1-mesa-dri\nVersion: 99.0.0\nDescription: Dummy package for libgl1-mesa-dri\n' >> libgl1-mesa-dri \
|
||||||
|
&& equivs-build libgl1-mesa-dri \
|
||||||
|
&& mv libgl1-mesa-dri_*.deb /libgl1-mesa-dri.deb \
|
||||||
|
&& equivs-control adwaita-icon-theme \
|
||||||
|
&& printf 'Section: misc\nPriority: optional\nStandards-Version: 3.9.2\nPackage: adwaita-icon-theme\nVersion: 99.0.0\nDescription: Dummy package for adwaita-icon-theme\n' >> adwaita-icon-theme \
|
||||||
|
&& equivs-build adwaita-icon-theme \
|
||||||
|
&& mv adwaita-icon-theme_*.deb /adwaita-icon-theme.deb
|
||||||
|
|
||||||
# Install the web browser (package firefox is available too)
|
FROM python:3.11-slim-bullseye
|
||||||
RUN apk update && \
|
|
||||||
apk add --no-cache firefox-esr dumb-init && \
|
|
||||||
rm -Rf /var/cache
|
|
||||||
|
|
||||||
# Copy FlareSolverr code
|
# Copy dummy packages
|
||||||
USER node
|
COPY --from=builder /*.deb /
|
||||||
RUN mkdir -p /home/node/flaresolverr
|
|
||||||
WORKDIR /home/node/flaresolverr
|
|
||||||
COPY --chown=node:node package.json package-lock.json tsconfig.json ./
|
|
||||||
COPY --chown=node:node src ./src/
|
|
||||||
|
|
||||||
# Install package. Skip installing the browser, we will use the installed package.
|
# Install dependencies and create flaresolverr user
|
||||||
ENV PUPPETEER_PRODUCT=firefox \
|
# You can test Chromium running this command inside the container:
|
||||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
# xvfb-run -s "-screen 0 1600x1200x24" chromium --no-sandbox
|
||||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/firefox
|
# The error traces is like this: "*** stack smashing detected ***: terminated"
|
||||||
RUN npm install && \
|
# To check the package versions available you can use this command:
|
||||||
npm run build && \
|
# apt-cache madison chromium
|
||||||
npm prune --production && \
|
WORKDIR /app
|
||||||
rm -rf /home/node/.npm
|
# Install dummy packages
|
||||||
|
RUN dpkg -i /libgl1-mesa-dri.deb \
|
||||||
|
&& dpkg -i /adwaita-icon-theme.deb \
|
||||||
|
# Install dependencies
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends chromium chromium-common chromium-driver xvfb dumb-init \
|
||||||
|
procps curl vim xauth libxml2-dev libxslt-dev gcc \
|
||||||
|
# Remove temporary files and hardware decoding libraries
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& rm -f /usr/lib/x86_64-linux-gnu/libmfxhw* \
|
||||||
|
&& rm -f /usr/lib/x86_64-linux-gnu/mfx/* \
|
||||||
|
# Create flaresolverr user
|
||||||
|
&& useradd --home-dir /app --shell /bin/sh flaresolverr \
|
||||||
|
&& mv /usr/bin/chromedriver chromedriver \
|
||||||
|
&& chown -R flaresolverr:flaresolverr .
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt \
|
||||||
|
# Remove temporary files
|
||||||
|
&& rm -rf /root/.cache
|
||||||
|
|
||||||
|
USER flaresolverr
|
||||||
|
|
||||||
|
RUN mkdir -p "/app/.config/chromium/Crash Reports/pending"
|
||||||
|
|
||||||
|
COPY src .
|
||||||
|
COPY package.json ../
|
||||||
|
|
||||||
EXPOSE 8191
|
EXPOSE 8191
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
EXPOSE 8192
|
||||||
CMD ["npm", "start"]
|
|
||||||
|
|
||||||
# docker build -t flaresolverr:custom .
|
# dumb-init avoids zombie chromium processes
|
||||||
# docker run -p 8191:8191 -e LOG_LEVEL=debug flaresolverr:custom
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
|
|
||||||
|
CMD ["/usr/local/bin/python", "-u", "/app/flaresolverr.py"]
|
||||||
|
|
||||||
|
# Local build
|
||||||
|
# docker build -t ngosang/flaresolverr:3.3.21 .
|
||||||
|
# docker run -p 8191:8191 ngosang/flaresolverr:3.3.21
|
||||||
|
|
||||||
|
# Multi-arch build
|
||||||
|
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
|
# docker buildx create --use
|
||||||
|
# docker buildx build -t ngosang/flaresolverr:3.3.21 --platform linux/386,linux/amd64,linux/arm/v7,linux/arm64/v8 .
|
||||||
|
# add --push to publish in DockerHub
|
||||||
|
|
||||||
|
# Test multi-arch build
|
||||||
|
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||||
|
# docker buildx create --use
|
||||||
|
# docker buildx build -t ngosang/flaresolverr:3.3.21 --platform linux/arm/v7 --load .
|
||||||
|
# docker run -p 8191:8191 --platform linux/arm/v7 ngosang/flaresolverr:3.3.21
|
||||||
|
|||||||
3
LICENSE
3
LICENSE
@@ -1,7 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2020 Diego Heras (ngosang)
|
Copyright (c) 2023 Diego Heras (ngosang / ngosang@hotmail.es)
|
||||||
Copyright (c) 2020 Noah Cardoza (NoahCardoza)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
191
README.md
191
README.md
@@ -4,18 +4,18 @@
|
|||||||
[](https://hub.docker.com/r/flaresolverr/flaresolverr/)
|
[](https://hub.docker.com/r/flaresolverr/flaresolverr/)
|
||||||
[](https://github.com/FlareSolverr/FlareSolverr/issues)
|
[](https://github.com/FlareSolverr/FlareSolverr/issues)
|
||||||
[](https://github.com/FlareSolverr/FlareSolverr/pulls)
|
[](https://github.com/FlareSolverr/FlareSolverr/pulls)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X5NJLLX5GLTV6&source=url)
|
[](https://www.paypal.com/paypalme/diegoheras0xff)
|
||||||
[](https://www.buymeacoffee.com/ngosang)
|
[](https://www.blockchain.com/btc/address/13Hcv77AdnFWEUZ9qUpoPBttQsUT7q9TTh)
|
||||||
[](https://en.cryptobadges.io/donate/13Hcv77AdnFWEUZ9qUpoPBttQsUT7q9TTh)
|
[](https://www.blockchain.com/eth/address/0x0D1549BbB00926BF3D92c1A8A58695e982f1BE2E)
|
||||||
|
|
||||||
FlareSolverr is a proxy server to bypass Cloudflare protection.
|
FlareSolverr is a proxy server to bypass Cloudflare and DDoS-GUARD protection.
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
FlareSolverr starts a proxy server and it waits for user requests in an idle state using few resources.
|
FlareSolverr starts a proxy server, and it waits for user requests in an idle state using few resources.
|
||||||
When some request arrives, it uses [puppeteer](https://github.com/puppeteer/puppeteer) with the
|
When some request arrives, it uses [Selenium](https://www.selenium.dev) with the
|
||||||
[stealth plugin](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth)
|
[undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver)
|
||||||
to create a headless browser (Firefox). It opens the URL with user parameters and waits until the Cloudflare challenge
|
to create a web browser (Chrome). It opens the URL with user parameters and waits until the Cloudflare challenge
|
||||||
is solved (or timeout). The HTML code and the cookies are sent back to the user, and those cookies can be used to
|
is solved (or timeout). The HTML code and the cookies are sent back to the user, and those cookies can be used to
|
||||||
bypass Cloudflare using other HTTP clients.
|
bypass Cloudflare using other HTTP clients.
|
||||||
|
|
||||||
@@ -37,13 +37,16 @@ Docker images are available in:
|
|||||||
* DockerHub => https://hub.docker.com/r/flaresolverr/flaresolverr
|
* DockerHub => https://hub.docker.com/r/flaresolverr/flaresolverr
|
||||||
|
|
||||||
Supported architectures are:
|
Supported architectures are:
|
||||||
| Architecture | Tag |
|
|
||||||
| :----: | --- |
|
|
||||||
| x86-64 | linux/amd64 |
|
|
||||||
| ARM64 | linux/arm64 |
|
|
||||||
| ARM32 | linux/arm/v7 |
|
|
||||||
|
|
||||||
We provide a `docker-compose.yml` configuration file. Clone this repository and execute `docker-compose up -d` to start
|
| Architecture | Tag |
|
||||||
|
|--------------|--------------|
|
||||||
|
| x86 | linux/386 |
|
||||||
|
| x86-64 | linux/amd64 |
|
||||||
|
| ARM32 | linux/arm/v7 |
|
||||||
|
| ARM64 | linux/arm64 |
|
||||||
|
|
||||||
|
We provide a `docker-compose.yml` configuration file. Clone this repository and execute
|
||||||
|
`docker-compose up -d` _(Compose V1)_ or `docker compose up -d` _(Compose V2)_ to start
|
||||||
the container.
|
the container.
|
||||||
|
|
||||||
If you prefer the `docker cli` execute the following command.
|
If you prefer the `docker cli` execute the following command.
|
||||||
@@ -56,23 +59,38 @@ docker run -d \
|
|||||||
ghcr.io/flaresolverr/flaresolverr:latest
|
ghcr.io/flaresolverr/flaresolverr:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If your host OS is Debian, make sure `libseccomp2` version is 2.5.x. You can check the version with `sudo apt-cache policy libseccomp2`
|
||||||
|
and update the package with `sudo apt install libseccomp2=2.5.1-1~bpo10+1` or `sudo apt install libseccomp2=2.5.1-1+deb11u1`.
|
||||||
|
Remember to restart the Docker daemon and the container after the update.
|
||||||
|
|
||||||
### Precompiled binaries
|
### Precompiled binaries
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
> Precompiled binaries are only available for x64 architecture. For other architectures see Docker images.
|
||||||
|
|
||||||
This is the recommended way for Windows users.
|
This is the recommended way for Windows users.
|
||||||
* Download the [FlareSolverr zip](https://github.com/FlareSolverr/FlareSolverr/releases) from the release's assets. It is available for Windows and Linux.
|
* Download the [FlareSolverr executable](https://github.com/FlareSolverr/FlareSolverr/releases) from the release's page. It is available for Windows x64 and Linux x64.
|
||||||
* Extract the zip file. FlareSolverr executable and firefox folder must be in the same directory.
|
|
||||||
* Execute FlareSolverr binary. In the environment variables section you can find how to change the configuration.
|
* Execute FlareSolverr binary. In the environment variables section you can find how to change the configuration.
|
||||||
|
|
||||||
### From source code
|
### From source code
|
||||||
|
|
||||||
This is the recommended way for macOS users and for developers.
|
> **Warning**
|
||||||
* Install [NodeJS](https://nodejs.org/).
|
> Installing from source code only works for x64 architecture. For other architectures see Docker images.
|
||||||
|
|
||||||
|
* Install [Python 3.11](https://www.python.org/downloads/).
|
||||||
|
* Install [Chrome](https://www.google.com/intl/en_us/chrome/) (all OS) or [Chromium](https://www.chromium.org/getting-involved/download-chromium/) (just Linux, it doesn't work in Windows) web browser.
|
||||||
|
* (Only in Linux) Install [Xvfb](https://en.wikipedia.org/wiki/Xvfb) package.
|
||||||
|
* (Only in macOS) Install [XQuartz](https://www.xquartz.org/) package.
|
||||||
* Clone this repository and open a shell in that path.
|
* Clone this repository and open a shell in that path.
|
||||||
* Run `export PUPPETEER_PRODUCT=firefox` (Linux/macOS) or `set PUPPETEER_PRODUCT=firefox` (Windows).
|
* Run `pip install -r requirements.txt` command to install FlareSolverr dependencies.
|
||||||
* Run `npm install` command to install FlareSolverr dependencies.
|
* Run `python src/flaresolverr.py` command to start FlareSolverr.
|
||||||
* Run `node node_modules/puppeteer/install.js` to install Firefox.
|
|
||||||
* Run `npm run build` command to compile TypeScript code.
|
### From source code (FreeBSD/TrueNAS CORE)
|
||||||
* Run `npm start` command to start FlareSolverr.
|
|
||||||
|
* Run `pkg install chromium python39 py39-pip xorg-vfbserver` command to install the required dependencies.
|
||||||
|
* Clone this repository and open a shell in that path.
|
||||||
|
* Run `python3.9 -m pip install -r requirements.txt` command to install FlareSolverr dependencies.
|
||||||
|
* Run `python3.9 src/flaresolverr.py` command to start FlareSolverr.
|
||||||
|
|
||||||
### Systemd service
|
### Systemd service
|
||||||
|
|
||||||
@@ -80,17 +98,43 @@ We provide an example Systemd unit file `flaresolverr.service` as reference. You
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Example request:
|
Example Bash request:
|
||||||
```bash
|
```bash
|
||||||
curl -L -X POST 'http://localhost:8191/v1' \
|
curl -L -X POST 'http://localhost:8191/v1' \
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"cmd": "request.get",
|
"cmd": "request.get",
|
||||||
"url":"http://www.google.com/",
|
"url": "http://www.google.com/",
|
||||||
"maxTimeout": 60000
|
"maxTimeout": 60000
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example Python request:
|
||||||
|
```py
|
||||||
|
import requests
|
||||||
|
|
||||||
|
url = "http://localhost:8191/v1"
|
||||||
|
headers = {"Content-Type": "application/json"}
|
||||||
|
data = {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": "http://www.google.com/",
|
||||||
|
"maxTimeout": 60000
|
||||||
|
}
|
||||||
|
response = requests.post(url, headers=headers, json=data)
|
||||||
|
print(response.text)
|
||||||
|
```
|
||||||
|
|
||||||
|
Example PowerShell request:
|
||||||
|
```ps1
|
||||||
|
$body = @{
|
||||||
|
cmd = "request.get"
|
||||||
|
url = "http://www.google.com/"
|
||||||
|
maxTimeout = 60000
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
irm -UseBasicParsing 'http://localhost:8191/v1' -Headers @{"Content-Type"="application/json"} -Method Post -Body $body
|
||||||
|
```
|
||||||
|
|
||||||
### Commands
|
### Commands
|
||||||
|
|
||||||
#### + `sessions.create`
|
#### + `sessions.create`
|
||||||
@@ -101,9 +145,10 @@ cookies for the browser to use.
|
|||||||
|
|
||||||
This also speeds up the requests since it won't have to launch a new browser instance for every request.
|
This also speeds up the requests since it won't have to launch a new browser instance for every request.
|
||||||
|
|
||||||
Parameter | Notes
|
| Parameter | Notes |
|
||||||
|--|--|
|
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
session | Optional. The session ID that you want to be assigned to the instance. If isn't set a random UUID will be assigned.
|
| session | Optional. The session ID that you want to be assigned to the instance. If isn't set a random UUID will be assigned. |
|
||||||
|
| proxy | Optional, default disabled. Eg: `"proxy": {"url": "http://127.0.0.1:8888"}`. You must include the proxy schema in the URL: `http://`, `socks4://` or `socks5://`. Authorization (username/password) is supported. Eg: `"proxy": {"url": "http://127.0.0.1:8888", "username": "testuser", "password": "testpass"}` |
|
||||||
|
|
||||||
#### + `sessions.list`
|
#### + `sessions.list`
|
||||||
|
|
||||||
@@ -128,22 +173,24 @@ Example response:
|
|||||||
This will properly shutdown a browser instance and remove all files associated with it to free up resources for a new
|
This will properly shutdown a browser instance and remove all files associated with it to free up resources for a new
|
||||||
session. When you no longer need to use a session you should make sure to close it.
|
session. When you no longer need to use a session you should make sure to close it.
|
||||||
|
|
||||||
Parameter | Notes
|
| Parameter | Notes |
|
||||||
|--|--|
|
|-----------|-----------------------------------------------|
|
||||||
session | The session ID that you want to be destroyed.
|
| session | The session ID that you want to be destroyed. |
|
||||||
|
|
||||||
#### + `request.get`
|
#### + `request.get`
|
||||||
|
|
||||||
Parameter | Notes
|
| Parameter | Notes |
|
||||||
|--|--|
|
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
url | Mandatory
|
| url | Mandatory |
|
||||||
session | Optional. Will send the request from and existing browser instance. If one is not sent it will create a temporary instance that will be destroyed immediately after the request is completed.
|
| session | Optional. Will send the request from and existing browser instance. If one is not sent it will create a temporary instance that will be destroyed immediately after the request is completed. |
|
||||||
maxTimeout | Optional, default value 60000. Max timeout to solve the challenge in milliseconds.
|
| session_ttl_minutes | Optional. FlareSolverr will automatically rotate expired sessions based on the TTL provided in minutes. |
|
||||||
cookies | Optional. Will be used by the headless browser. Follow [this](https://github.com/puppeteer/puppeteer/blob/v3.3.0/docs/api.md#pagesetcookiecookies) format.
|
| maxTimeout | Optional, default value 60000. Max timeout to solve the challenge in milliseconds. |
|
||||||
returnOnlyCookies | Optional, default false. Only returns the cookies. Response data, headers and other parts of the response are removed.
|
| cookies | Optional. Will be used by the headless browser. Eg: `"cookies": [{"name": "cookie1", "value": "value1"}, {"name": "cookie2", "value": "value2"}]`. |
|
||||||
proxy | Optional, default disabled. Eg: `"proxy": {"url": "http://127.0.0.1:8888"}`. Authorization (username/password) is not supported.
|
| returnOnlyCookies | Optional, default false. Only returns the cookies. Response data, headers and other parts of the response are removed. |
|
||||||
|
| proxy | Optional, default disabled. Eg: `"proxy": {"url": "http://127.0.0.1:8888"}`. You must include the proxy schema in the URL: `http://`, `socks4://` or `socks5://`. Authorization (username/password) is not supported. (When the `session` parameter is set, the proxy is ignored; a session specific proxy can be set in `sessions.create`.) |
|
||||||
|
|
||||||
:warning: If you want to use Cloudflare clearance cookie in your scripts, make sure you use the FlareSolverr User-Agent too. If they don't match you will see the challenge.
|
> **Warning**
|
||||||
|
> If you want to use Cloudflare clearance cookie in your scripts, make sure you use the FlareSolverr User-Agent too. If they don't match you will see the challenge.
|
||||||
|
|
||||||
Example response from running the `curl` above:
|
Example response from running the `curl` above:
|
||||||
|
|
||||||
@@ -208,36 +255,68 @@ Example response from running the `curl` above:
|
|||||||
|
|
||||||
This is the same as `request.get` but it takes one more param:
|
This is the same as `request.get` but it takes one more param:
|
||||||
|
|
||||||
Parameter | Notes
|
| Parameter | Notes |
|
||||||
|--|--|
|
|-----------|--------------------------------------------------------------------------|
|
||||||
postData | Must be a string with `application/x-www-form-urlencoded`. Eg: `postData": "a=b&c=d"`
|
| postData | Must be a string with `application/x-www-form-urlencoded`. Eg: `a=b&c=d` |
|
||||||
|
|
||||||
## Environment variables
|
## Environment variables
|
||||||
|
|
||||||
Name | Default | Notes
|
| Name | Default | Notes |
|
||||||
|--|--|--|
|
|--------------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
LOG_LEVEL | info | Verbosity of the logging. Use `LOG_LEVEL=debug` for more information.
|
| LOG_LEVEL | info | Verbosity of the logging. Use `LOG_LEVEL=debug` for more information. |
|
||||||
LOG_HTML | false | Only for debugging. If `true` all HTML that passes through the proxy will be logged to the console in `debug` level.
|
| LOG_HTML | false | Only for debugging. If `true` all HTML that passes through the proxy will be logged to the console in `debug` level. |
|
||||||
CAPTCHA_SOLVER | none | Captcha solving method. It is used when a captcha is encountered. See the Captcha Solvers section.
|
| CAPTCHA_SOLVER | none | Captcha solving method. It is used when a captcha is encountered. See the Captcha Solvers section. |
|
||||||
TZ | UTC | Timezone used in the logs and the web browser. Example: `TZ=Europe/London`.
|
| TZ | UTC | Timezone used in the logs and the web browser. Example: `TZ=Europe/London`. |
|
||||||
HEADLESS | true | Only for debugging. To run the web browser in headless mode or visible.
|
| LANG | none | Language used in the web browser. Example: `LANG=en_GB`. |
|
||||||
PORT | 8191 | Listening port. You don't need to change this if you are running on Docker.
|
| HEADLESS | true | Only for debugging. To run the web browser in headless mode or visible. |
|
||||||
HOST | 0.0.0.0 | Listening interface. You don't need to change this if you are running on Docker.
|
| BROWSER_TIMEOUT | 40000 | If you are experiencing errors/timeouts because your system is slow, you can try to increase this value. Remember to increase the `maxTimeout` parameter too. |
|
||||||
|
| TEST_URL | https://www.google.com | FlareSolverr makes a request on start to make sure the web browser is working. You can change that URL if it is blocked in your country. |
|
||||||
|
| PORT | 8191 | Listening port. You don't need to change this if you are running on Docker. |
|
||||||
|
| HOST | 0.0.0.0 | Listening interface. You don't need to change this if you are running on Docker. |
|
||||||
|
| PROMETHEUS_ENABLED | false | Enable Prometheus exporter. See the Prometheus section below. |
|
||||||
|
| PROMETHEUS_PORT | 8192 | Listening port for Prometheus exporter. See the Prometheus section below. |
|
||||||
|
|
||||||
Environment variables are set differently depending on the operating system. Some examples:
|
Environment variables are set differently depending on the operating system. Some examples:
|
||||||
* Docker: Take a look at the Docker section in this document. Environment variables can be set in the `docker-compose.yml` file or in the Docker CLI command.
|
* Docker: Take a look at the Docker section in this document. Environment variables can be set in the `docker-compose.yml` file or in the Docker CLI command.
|
||||||
* Linux: Run `export LOG_LEVEL=debug` and then start FlareSolverr in the same shell.
|
* Linux: Run `export LOG_LEVEL=debug` and then run `flaresolverr` in the same shell.
|
||||||
* Windows: Open `cmd.exe`, run `set LOG_LEVEL=debug` and then start FlareSolverr in the same shell.
|
* Windows: Open `cmd.exe`, run `set LOG_LEVEL=debug` and then run `flaresolverr.exe` in the same shell.
|
||||||
|
|
||||||
|
## Prometheus exporter
|
||||||
|
|
||||||
|
The Prometheus exporter for FlareSolverr is disabled by default. It can be enabled with the environment variable `PROMETHEUS_ENABLED`. If you are using Docker make sure you expose the `PROMETHEUS_PORT`.
|
||||||
|
|
||||||
|
Example metrics:
|
||||||
|
```shell
|
||||||
|
# HELP flaresolverr_request_total Total requests with result
|
||||||
|
# TYPE flaresolverr_request_total counter
|
||||||
|
flaresolverr_request_total{domain="nowsecure.nl",result="solved"} 1.0
|
||||||
|
# HELP flaresolverr_request_created Total requests with result
|
||||||
|
# TYPE flaresolverr_request_created gauge
|
||||||
|
flaresolverr_request_created{domain="nowsecure.nl",result="solved"} 1.690141657157109e+09
|
||||||
|
# HELP flaresolverr_request_duration Request duration in seconds
|
||||||
|
# TYPE flaresolverr_request_duration histogram
|
||||||
|
flaresolverr_request_duration_bucket{domain="nowsecure.nl",le="0.0"} 0.0
|
||||||
|
flaresolverr_request_duration_bucket{domain="nowsecure.nl",le="10.0"} 1.0
|
||||||
|
flaresolverr_request_duration_bucket{domain="nowsecure.nl",le="25.0"} 1.0
|
||||||
|
flaresolverr_request_duration_bucket{domain="nowsecure.nl",le="50.0"} 1.0
|
||||||
|
flaresolverr_request_duration_bucket{domain="nowsecure.nl",le="+Inf"} 1.0
|
||||||
|
flaresolverr_request_duration_count{domain="nowsecure.nl"} 1.0
|
||||||
|
flaresolverr_request_duration_sum{domain="nowsecure.nl"} 5.858
|
||||||
|
# HELP flaresolverr_request_duration_created Request duration in seconds
|
||||||
|
# TYPE flaresolverr_request_duration_created gauge
|
||||||
|
flaresolverr_request_duration_created{domain="nowsecure.nl"} 1.6901416571570296e+09
|
||||||
|
```
|
||||||
|
|
||||||
## Captcha Solvers
|
## Captcha Solvers
|
||||||
|
|
||||||
:warning: At this time none of the captcha solvers work. You can check the status in the open issues. Any help is welcome.
|
> **Warning**
|
||||||
|
> At this time none of the captcha solvers work. You can check the status in the open issues. Any help is welcome.
|
||||||
|
|
||||||
Sometimes CloudFlare not only gives mathematical computations and browser tests, sometimes they also require the user to
|
Sometimes CloudFlare not only gives mathematical computations and browser tests, sometimes they also require the user to
|
||||||
solve a captcha.
|
solve a captcha.
|
||||||
If this is the case, FlareSolverr will return the error `Captcha detected but no automatic solver is configured.`
|
If this is the case, FlareSolverr will return the error `Captcha detected but no automatic solver is configured.`
|
||||||
|
|
||||||
FlareSolverr can be customized to solve the captchas automatically by setting the environment variable `CAPTCHA_SOLVER`
|
FlareSolverr can be customized to solve the CAPTCHA automatically by setting the environment variable `CAPTCHA_SOLVER`
|
||||||
to the file name of one of the adapters inside the [/captcha](src/captcha) directory.
|
to the file name of one of the adapters inside the [/captcha](src/captcha) directory.
|
||||||
|
|
||||||
## Related projects
|
## Related projects
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
const fs = require('fs')
|
|
||||||
const path = require('path')
|
|
||||||
const { execSync } = require('child_process')
|
|
||||||
const archiver = require('archiver')
|
|
||||||
const https = require('https')
|
|
||||||
const puppeteer = require('puppeteer')
|
|
||||||
const version = 'v' + require('./package.json').version;
|
|
||||||
|
|
||||||
function getFirefoxNightlyVersion() {
|
|
||||||
const firefoxVersions = 'https://product-details.mozilla.org/1.0/firefox_versions.json';
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let data = '';
|
|
||||||
https
|
|
||||||
.get(firefoxVersions, (r) => {
|
|
||||||
if (r.statusCode >= 400)
|
|
||||||
return reject(new Error(`Got status code ${r.statusCode}`));
|
|
||||||
r.on('data', (chunk) => {
|
|
||||||
data += chunk;
|
|
||||||
});
|
|
||||||
r.on('end', () => {
|
|
||||||
try {
|
|
||||||
const versions = JSON.parse(data);
|
|
||||||
return resolve(versions.FIREFOX_NIGHTLY);
|
|
||||||
} catch {
|
|
||||||
return reject(new Error('Firefox version not found'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.on('error', reject);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const builds = [
|
|
||||||
{
|
|
||||||
platform: 'linux',
|
|
||||||
firefoxFolder: 'firefox',
|
|
||||||
fsExec: 'flaresolverr-linux',
|
|
||||||
fsZipExec: 'flaresolverr',
|
|
||||||
fsZipName: 'linux-x64',
|
|
||||||
fsLicenseName: 'LICENSE'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
platform: 'win64',
|
|
||||||
firefoxFolder: 'firefox',
|
|
||||||
fsExec: 'flaresolverr-win.exe',
|
|
||||||
fsZipExec: 'flaresolverr.exe',
|
|
||||||
fsZipName: 'windows-x64',
|
|
||||||
fsLicenseName: 'LICENSE.txt'
|
|
||||||
}
|
|
||||||
// todo: this has to be build in macOS (hdiutil is required). changes required in sessions.ts too
|
|
||||||
// {
|
|
||||||
// platform: 'mac',
|
|
||||||
// firefoxFolder: 'firefox',
|
|
||||||
// fsExec: 'flaresolverr-macos',
|
|
||||||
// fsZipExec: 'flaresolverr',
|
|
||||||
// fsZipName: 'macos',
|
|
||||||
// fsLicenseName: 'LICENSE'
|
|
||||||
// }
|
|
||||||
]
|
|
||||||
|
|
||||||
// generate executables
|
|
||||||
console.log('Generating executables...')
|
|
||||||
if (fs.existsSync('bin')) {
|
|
||||||
fs.rmSync('bin', { recursive: true })
|
|
||||||
}
|
|
||||||
execSync('./node_modules/.bin/pkg -t node14-win-x64,node14-linux-x64 --out-path bin .')
|
|
||||||
// execSync('./node_modules/.bin/pkg -t node14-win-x64,node14-mac-x64,node14-linux-x64 --out-path bin .')
|
|
||||||
|
|
||||||
// get firefox revision
|
|
||||||
const revision = await getFirefoxNightlyVersion();
|
|
||||||
|
|
||||||
// download firefox and zip together
|
|
||||||
for (const os of builds) {
|
|
||||||
console.log('Building ' + os.fsZipName + ' artifact')
|
|
||||||
|
|
||||||
// download firefox
|
|
||||||
console.log(`Downloading firefox ${revision} for ${os.platform} ...`)
|
|
||||||
const f = puppeteer.createBrowserFetcher({
|
|
||||||
product: 'firefox',
|
|
||||||
platform: os.platform,
|
|
||||||
path: path.join(__dirname, 'bin', 'puppeteer')
|
|
||||||
})
|
|
||||||
await f.download(revision)
|
|
||||||
|
|
||||||
// compress in zip
|
|
||||||
console.log('Compressing zip file...')
|
|
||||||
const zipName = 'bin/flaresolverr-' + version + '-' + os.fsZipName + '.zip'
|
|
||||||
const output = fs.createWriteStream(zipName)
|
|
||||||
const archive = archiver('zip')
|
|
||||||
|
|
||||||
output.on('close', function () {
|
|
||||||
console.log('File ' + zipName + ' created. Size: ' + archive.pointer() + ' bytes')
|
|
||||||
})
|
|
||||||
|
|
||||||
archive.on('error', function (err) {
|
|
||||||
throw err
|
|
||||||
})
|
|
||||||
|
|
||||||
archive.pipe(output)
|
|
||||||
|
|
||||||
archive.file('LICENSE', { name: 'flaresolverr/' + os.fsLicenseName })
|
|
||||||
archive.file('bin/' + os.fsExec, { name: 'flaresolverr/' + os.fsZipExec })
|
|
||||||
archive.directory('bin/puppeteer/' + os.platform + '-' + revision + '/' + os.firefoxFolder, 'flaresolverr/firefox')
|
|
||||||
if (os.platform === 'linux') {
|
|
||||||
archive.file('flaresolverr.service', { name: 'flaresolverr/flaresolverr.service' })
|
|
||||||
}
|
|
||||||
|
|
||||||
await archive.finalize()
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=FlareSolverr
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
SyslogIdentifier=flaresolverr
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5
|
|
||||||
Type=simple
|
|
||||||
User=flaresolverr
|
|
||||||
Group=flaresolverr
|
|
||||||
Environment="LOG_LEVEL=info"
|
|
||||||
Environment="CAPTCHA_SOLVER=none"
|
|
||||||
WorkingDirectory=/opt/flaresolverr
|
|
||||||
ExecStart=/opt/flaresolverr/flaresolverr
|
|
||||||
TimeoutStopSec=30
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
219
html_samples/cloudflare_captcha_hcaptcha_v1.html
Normal file
219
html_samples/cloudflare_captcha_hcaptcha_v1.html
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en-US">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Just a moment...</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||||
|
<meta name="robots" content="noindex,nofollow">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<link href="Just%20a%20moment_files/cf-errors.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
window._cf_chl_opt = {
|
||||||
|
cvId: '2',
|
||||||
|
cType: 'managed',
|
||||||
|
cNounce: '67839',
|
||||||
|
cRay: '732fbc436ab471ed',
|
||||||
|
cHash: 'dce5bd920f3aa51',
|
||||||
|
cUPMDTk: "\/search?q=2022&__cf_chl_tk=lkycIb1jDXlmFqiB7AXTwy38_EzYPvu79CCQyU9lhUE-1659201316-0-gaNycGzNCf0",
|
||||||
|
cFPWv: 'g',
|
||||||
|
cTTimeMs: '1000',
|
||||||
|
cTplV: 2,
|
||||||
|
cRq: {
|
||||||
|
ru: 'aHR0cHM6Ly8wbWFnbmV0LmNvbS9zZWFyY2g/cT0yMDIy',
|
||||||
|
ra: 'TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0OyBydjoxMDUuMCkgR2Vja28vMjAxMDAxMDEgRmlyZWZveC8xMDUuMA==',
|
||||||
|
rm: 'R0VU',
|
||||||
|
d: 'MqxNbbGfWazPaVMZ7GQRz02TV/pSUL9POWx0y4e7HFRwP1RTAxLc1RZRuHg+N/bGMuPj08kSx0UpcjEjMkSOqiU6I/64IDYbCJvey5rY07fkkljpZaYGTDZIoWdOWlgP3ky15ybZ42xMK4tfI1yJ+iFZCVgR6VBjJzi5I56j9Ijog2AvsoQW2TrguGpgKaT1LkhxWNElzBbvXWt1uyRgE19UQ9J/5vtxEwoh5wodHh7WE297n8uI1hpDgge2bDYQvwe+RDq3QAyhQOmymg+IIlt1y115v9R8k5ehT9TFY3vYvYnoJu9cOyHYprf9Z0jTNGxSTvLHYJbfq30Samu5fKfE0oZREZizvPUgUsJm2rRKkCY9VCdBkpO8vaUgIwIYkeWavtqdudjb3zEDBCD4cAH/xv3Bl1VRy2Qf7XlcbpElCOq06TDTQ1uGjyCqbVbvjesrOy0Dp2nXTjdfbkWvnN7mWpFlPUD7/41MUo9lc6V1Aj1Kjg6AKfVV4DUHpq6ZVnMHzrcPQLy4qD7CptcMpQKArZtJCRsUpgq8GWKJcU4dU8ZmyROAA+l+JEVnGbh2bsRdif4azh57OdjZfEKSa5c+AL3i66vyWAZCw9Wl6CAQdFTA+ixkbl8zKbCm8ulv',
|
||||||
|
t: 'MTY1OTIwMTMxNi4zOTIwMDA=',
|
||||||
|
m: '3l81qRkXiMTbjTzBtc0v1XwSheF46UfagbXVhYgbAVw=',
|
||||||
|
i1: 'Iu5a1gH3p9igzqBwncow9g==',
|
||||||
|
i2: 'PmNXozjc73unhnp/X0+kUQ==',
|
||||||
|
zh: 'qP4bnGc6j96JlnjNSE7HmQci3S9L50bHFtm4bQRjjKU=',
|
||||||
|
uh: 'SK3PXNkeRzZtkRARhJpbmZpCIiWQw6+5gpOE7vojWx4=',
|
||||||
|
hh: 'azXzJl8Ou22g0nN/9idVUoB9EqZ7fLmkSdDRHM3Lkmw=',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window._cf_chl_enter = function () { window._cf_chl_opt.p = 1 };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="Just%20a%20moment_files/v1.js"></script>
|
||||||
|
<script type="text/javascript" src="Just%20a%20moment_files/api.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="no-js">
|
||||||
|
|
||||||
|
<div class="privacy-pass">
|
||||||
|
<a rel="noopener noreferrer" href="https://addons.mozilla.org/en-US/firefox/addon/privacy-pass/"
|
||||||
|
target="_blank">
|
||||||
|
Privacy Pass
|
||||||
|
<span class="privacy-pass-icon-wrapper">
|
||||||
|
<div class="privacy-pass-icon"></div>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-wrapper" role="main">
|
||||||
|
<div class="main-content">
|
||||||
|
<h1 class="zone-name-title h1">
|
||||||
|
<img class="heading-favicon" src="Just%20a%20moment_files/favicon.ico"
|
||||||
|
onerror="this.onerror=null;this.parentNode.removeChild(this)">
|
||||||
|
0MAGNET.COM
|
||||||
|
</h1>
|
||||||
|
<h2 class="h2" id="cf-challenge-running">
|
||||||
|
Checking if the site connection is secure
|
||||||
|
</h2>
|
||||||
|
<div id="cf-challenge-stage" style="display: block;">
|
||||||
|
<div id="cf-challenge-hcaptcha-wrapper" class="captcha-prompt spacer">
|
||||||
|
<div style="display: none;" class="hcaptcha-box"><iframe src="Just%20a%20moment_files/hcaptcha.html"
|
||||||
|
title="widget containing checkbox for hCaptcha security challenge" tabindex="0"
|
||||||
|
scrolling="no" data-hcaptcha-widget-id="0tiueg8lyuj" data-hcaptcha-response=""
|
||||||
|
style="width: 303px; height: 78px; overflow: hidden;" frameborder="0"></iframe><textarea
|
||||||
|
id="h-captcha-response-0tiueg8lyuj" name="h-captcha-response"
|
||||||
|
style="display: none;"></textarea></div>
|
||||||
|
<div class="hcaptcha-box"><iframe src="Just%20a%20moment_files/hcaptcha_002.html"
|
||||||
|
title="widget containing checkbox for hCaptcha security challenge" tabindex="0"
|
||||||
|
scrolling="no" data-hcaptcha-widget-id="10tlmhzz0qyq" data-hcaptcha-response=""
|
||||||
|
style="width: 303px; height: 78px; overflow: hidden;" frameborder="0"></iframe><textarea
|
||||||
|
id="h-captcha-response-10tlmhzz0qyq" name="h-captcha-response"
|
||||||
|
style="display: none;"></textarea></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-spinner" class="spacer loading-spinner" style="display: none; visibility: hidden;">
|
||||||
|
<div class="lds-ring">
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<noscript>
|
||||||
|
<div id="cf-challenge-error-title">
|
||||||
|
<div class="h2">
|
||||||
|
<span class="icon-wrapper">
|
||||||
|
<div class="heading-icon warning-icon"></div>
|
||||||
|
</span>
|
||||||
|
<span id="cf-challenge-error-text">
|
||||||
|
Enable JavaScript and cookies to continue
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<div
|
||||||
|
style="display:none;background-image:url('/cdn-cgi/images/trace/captcha/nojs/transparent.gif?ray=732fbc436ab471ed')">
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-body-text" class="core-msg spacer">
|
||||||
|
0magnet.com needs to review the security of your connection before
|
||||||
|
proceeding.
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-fact-wrapper" style="display: block; visibility: visible;" class="fact spacer hidden">
|
||||||
|
<span class="fact-title">Did you know</span> <span id="cf-challenge-fact" class="body-text">the first
|
||||||
|
botnet in 2003 took over 500-1000 devices? Today, botnets take over millions of devices at
|
||||||
|
once.</span>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-explainer-expandable" class="hidden expandable body-text spacer"
|
||||||
|
style="display: block; visibility: visible;">
|
||||||
|
<div class="expandable-title" id="cf-challenge-explainer-summary"><button class="expandable-summary-btn"
|
||||||
|
id="cf-challenge-explainer-btn" type="button"> Why am I seeing this page? <span
|
||||||
|
class="caret-icon-wrapper">
|
||||||
|
<div class="caret-icon"></div>
|
||||||
|
</span> </button> </div>
|
||||||
|
<div class="expandable-details" id="cf-challenge-explainer-details">
|
||||||
|
Requests from malicious bots can pose as legitimate traffic.
|
||||||
|
Occasionally, you may see this page while the site ensures that the
|
||||||
|
connection is secure.</div>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-success" style="display: none;">
|
||||||
|
<div class="h2"><span class="icon-wrapper"><img class="heading-icon" alt="Success icon"
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAANlBMVEUAAAAxMTEwMDAxMTExMTEwMDAwMDAwMDAxMTExMTExMTEwMDAwMDAxMTExMTEwMDAwMDAxMTHB9N+uAAAAEXRSTlMA3zDvfyBAEJC/n3BQz69gX7VMkcMAAAGySURBVEjHnZZbFoMgDEQJiDzVuv/NtgbtFGuQ4/zUKpeMIQbUhXSKE5l1XSn4pFWHRm/WShT1HRLWC01LGxFEVkCc30eYkLJ1Sjk9pvkw690VY6k8DWP9OM9yMG0Koi+mi8XA36NXmW0UXra4eJ3iwHfrfXVlgL0NqqGBHdqfeQhMmyJ48WDuKP81h3+SMPeRKkJcSXiLUK4XTHCjESOnz1VUXQoc6lgi2x4cI5aTQ201Mt8wHysI5fc05M5c81uZEtHcMKhxZ7iYEty1GfhLvGKpm+EYkdGxm1F5axmcB93DoORIbXfdN7f+hlFuyxtDP+sxtBnF43cIYwaZAWRgzxIoiXEMESoPlMhwLRDXeK772CAzXEdBRV7cmnoVBp0OSlyGidEzJTFq5hhcsA5388oSGM6b5p+qjpZrBlMS9xj4AwXmz108ukU1IomM3ceiW0CDwHCqp1NjAqXlFrbga+xuloQJ+tuyfbIBPNpqnmxqT7dPaOnZqBfhSBCteJAxWj58zLk2xgg+SPGYM6dRO6WczSnIxxwEExRaO+UyCUhbOp7CGQ+kxSUfNtLQFC+Po29vvy7jj4y0yAAAAABJRU5ErkJggg=="></span>Connection
|
||||||
|
is secure</div>
|
||||||
|
<div class="core-msg spacer">Proceeding...</div>
|
||||||
|
</div>
|
||||||
|
<form id="challenge-form"
|
||||||
|
action="/search?q=2022&__cf_chl_f_tk=lkycIb1jDXlmFqiB7AXTwy38_EzYPvu79CCQyU9lhUE-1659201316-0-gaNycGzNCf0"
|
||||||
|
method="POST" enctype="application/x-www-form-urlencoded">
|
||||||
|
<input type="hidden" name="md"
|
||||||
|
value="P4fDbSohR3e3VZmGdBSN0Gd8t8ueht.ZVgSdQYwa45Y-1659201316-0-AesEKnKN8eJLiLESJle3R0T3fwKbVMlX09CR0sIU1LruDXen0nSlT2a5OpMUFYR7HQMGcF9Ja227n2p2D2ffUlWHPVeFX-YSNiewLZA3XuAQmOn-1DyWKA-SaMH_MW2vOSC7PCHAdJDhoRWjM_o3MyKziopj3WmDcaCI_ikk68bJTIValZ_e9tO7hmHC8zjsxDC8kXmI0tbrhyW5nyS2hRlx_ZVRcRHbHsVRN0-FGtEbCoaHmnp-q0N4AYhCJXofYRunPcSG_Y1iWMk-7ofOXON_gO7oGG_8-WWD5EG1jaz2ldpNO1RTkS7dQvTiC1Io1qAsVnQtokEaDR2zoWK_MF-hz6tOmuJIDgnAoH6vPFAa9EyJOUiG2RV-3q1CKTUgr82XRJw5CaXpN0QeBq0xHxFl5mzkFO8xqQsRnPkGUKtxBQ58syPIhR4AvNp8HA028gUNmaztJZ9i2UcWydut4VghHsoJjS5DEKTamjJhNrrkargjXUekXTfKXMVKCXxo0NFObTmKwzsNB5hrk3M43KzZCOOgTnqsrVUk54bAeDsr4qmTVW2wVk-0u78QpV2JFFOIJxRLikPmqo9CUokgUJ_IPsEjA5Q3kjrf9yq2OHU0MkwzLFNOAyc5N3A4WSYp91kESwxM98qFetpAZ0R3LID2c2-MraHnpOI2Xn4bxbDIdUPmjy6VB8Huuuf6M-o3Tw">
|
||||||
|
<input type="hidden" name="r"
|
||||||
|
value="bdZ7.nm8dGOZxq3EDOv_Kx7nKVv68q7b0RARXAlR9kQ-1659201316-0-AawyK3x4GgWasA2OtBBEp9Ea52qs8zEWwnQJxLWUnC+1jqlxaKHTIHeVQjvrTl/ccu6QA41yrSTKvazKiv6zQEiDj/6ziYkhldx+oJ7SqgMzPozzza1jofsGpCCPAzIlDicF+7sh4WKOxUJOeHgHCgfEZF/MPNsaahvbQ10U8Ei9tmvj8c2tkoybya75Bj5XHPPu0S9hnOH7S24ltm9vmyHlttI7uuI962FzPCTGjuAl4R/5+06WVAzBCJrS4biDNIuyYe22PtLl4b3Yf55eW7AFgyzKgddsohZJuNNliKyD6cusHDhm7MYpnXc5zwTdCbt6KGK/tBaylNyYwH/WBAUhyRYN5EVt9/iIKHrb+P6Z0RL4nO3BtQE/Zwx1VC3g1Wy4PPQJjqLixQptzl5eIzu43JIO/LBvT/mWuheH4eoPlghvyMYwfHcs7B4d7FCv1Tj9Skp9Fcj6HBAZlq/ss/eIwk7oOcTviQs+EUF9/yYatgtpXX9RCyvhMU6/ghOLfXRmOpAzsmoGnVqEpc2IMlZegYtieLveXU35cGJMI6wCR2ciCJIX995vLuL/4BdCAMEhyMAUWxtaCD2ZfRHyOWKNuf80w9k6/Ofhu7RevCr2mjQJAVTyE2OWWgOUuYJ4pZim93J7slMXieL3S5/JM08Q8g179Of7dzpN/oG7s80ljxAiCprpUAwpEmNiqNJN//v0e9KxknhCHeAWSAe8IeXbp5PSEQHXTmsqOFRkpud1pTsETcNbdonk8XMyv8mZRcFPVWRRWUb8hupn/d+x9r6mOdKdJkH8ZZ0R30LG0SLPYEvsVr2yU9o+uCZrRWkuE3SP3Lq3BIx+0vtm0DOvj6cODxy5/4Zm4x7LIpSa9wr69Rs2x+t+U5ydUupZ7oiAbWfYZSXHpmB0zJYOLMPJZcut50J/IgWuTMda8QBcTG3jRr4BTwpcmBZRmddfOJYgD7EMpOi1HgwLnS7l5QELafaMn0Hl6G774GVy4lEK2jURG9IEE3PV1m5Y903pqldFkJQsMxdisJWOzVjbtf41fxxnt4cQgiDQhktqCwg8xP6ijzPeWgvQHL5fMq61cQ5/4HB+yt9wKWMlBfUJR+ocI2MYx2nUWz+0BwCnTU29D9bx1xkir9bsnUnfOlfRDO2OEvI0iTe82666rVQO9XqTEz3POxrJYzLcSC9fTHpHfmCVwT2zWGGLi6pW5kqZh/uzSQ12MSvF5+dwvhe7yRks5gwMhnDHMQFyxKw3Xxm+dq2Ix/1uUucOhCu2L72j/NIwkF3Z7O7afY9nIu+NqMe8PbPJjq5ovEluosQfAMzWJH5Va8iur8o6K1y6hm7XFdNYAR+uCtxMw6WzF58QWVXXrDvfPeBMaNz+VVCnGP9elAwv62tc4Uh2SCbKbWdZchtLHgrJgYgQtCMhBDh0AXzE6ubbtfm9jE2vWcPj5jbo8U72i1pL2j8Xfr562Xc2WrQ7tKvSFQepGxfu2XgF7q55XKVqrnrBeXxZViUkB/gyXxI26CfrVfPLW+sYUo3JS+eCjyn2K7phv+630ixdpKrRJCTmkP3G8tcoLTJCB67/pbz+dXiNSB4JlHf4i3FVRkr8TAWS2zuMjJhB+ZyxnrGq/m7KSwpEEqgSCpOrQ5nkeoKIOyITfe9EPBSy9QtYDK+SAhUiLnICVURK7kGgrhZuKyK5/nyK9l7ffg16aaChJBisPBeiYsTDHlAeq0GbW7VR/jQDAVtVldeyD/dM5rJ4X+wl3A+faYD1OUxYT3n8dMs+E/1jLnYixXJpo7iXCqlTV3phOatg4XDQ5Bj6EYQIljVI4x2e8XHspcETIa0WepLsZF7WUtY7KbN8ZyDBFXgTMb4lzPmWyY8hZ05uX8EBKqUJhWh91AUob/OpJdf+u3axDDeRgsjl8K6CFM/5uQKo93co3KPqGZiqx0JoVj1t6KGxkrzYsgwlrTyeL44cEgr0zRQz5oFExuwHGYyogbHZ8EvU1eoiJ3IuQFxUH/1ULidfGtB371RYfz9gqONi1KiVzJ+zLjw+4HgMKXOV+ra09Dyg+eyUNfHillLXkhKWVoDpUhc+r46W6vXFp3oMKUWTRM0dE7iHofo+0tHb73d3ID2blRXgUeoMCQwOptoAYlFBIUYjggrIhd1AMC8TiZmiNULyP5imDePwcfq+ZjGH3o8VKRI2FcoFmChQegGco6pEbB5DxCguDuJbFRwGH4t9T0y74ZhlZiTNKA4xXsQnfIBEC5qz3mkcDAWoe73zqFAjp35JRVBjo3UDvehJppxzuoCXt9UbeuNEGll5/YJR4lfbUsEai0U6TFVleTTY53ofYCWEM6EnNDIToTFbm514YFTUSc4h8Qlq2fPeqC3IcCmirNT4Kf0FCO7MQrtGNFPJme2cpb/pZguS3pxxkKb4lOS+eGiUBGcSs1v3zHroJ+hum4wTJFRG0Yb99aCVQU44wgV3nKW7FZkXzwO3QY7nnkFI2kaAXerCPF4+Ho463g==">
|
||||||
|
|
||||||
|
<span style="display: none;"><span class="text-gray-600" data-translate="error">error code:
|
||||||
|
1020</span></span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var trkjs = document.createElement('img');
|
||||||
|
trkjs.setAttribute('src', '/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=732fbc436ab471ed');
|
||||||
|
trkjs.setAttribute('style', 'display: none');
|
||||||
|
document.body.appendChild(trkjs);
|
||||||
|
var cpo = document.createElement('script');
|
||||||
|
cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=732fbc436ab471ed';
|
||||||
|
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
|
||||||
|
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
|
||||||
|
history.replaceState(null, null, "\/search?q=2022&__cf_chl_rt_tk=lkycIb1jDXlmFqiB7AXTwy38_EzYPvu79CCQyU9lhUE-1659201316-0-gaNycGzNCf0" + window._cf_chl_opt.cOgUHash);
|
||||||
|
cpo.onload = function () {
|
||||||
|
history.replaceState(null, null, ogU);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(cpo);
|
||||||
|
}());
|
||||||
|
</script><img src="Just%20a%20moment_files/transparent.gif" style="display: none">
|
||||||
|
|
||||||
|
<div class="footer" role="contentinfo">
|
||||||
|
<div class="footer-inner">
|
||||||
|
<div class="clearfix diagnostic-wrapper">
|
||||||
|
<div class="ray-id">Ray ID: <code>732fbc436ab471ed</code></div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
Performance & security by
|
||||||
|
<a rel="noopener noreferrer" href="https://www.cloudflare.com/" target="_blank">Cloudflare</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div style="background-color: rgb(255, 255, 255); border: 1px solid rgb(215, 215, 215); box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 4px; border-radius: 4px; left: -10000px; top: -10000px; z-index: -2147483648; position: absolute; transition: opacity 0.15s ease-out 0s; opacity: 0; visibility: hidden;"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div style="position: relative; z-index: 1;"><iframe src="Just%20a%20moment_files/hcaptcha_003.html"
|
||||||
|
title="Main content of the hCaptcha challenge" scrolling="no"
|
||||||
|
style="border: 0px none; z-index: 2000000000; position: relative;" frameborder="0"></iframe></div>
|
||||||
|
<div
|
||||||
|
style="width: 100%; height: 100%; position: fixed; pointer-events: none; top: 0px; left: 0px; z-index: 0; background-color: rgb(255, 255, 255); opacity: 0.05;">
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="border-width: 11px; position: absolute; pointer-events: none; margin-top: -11px; z-index: 1; right: 100%;">
|
||||||
|
<div
|
||||||
|
style="border-width: 10px; border-style: solid; border-color: transparent rgb(255, 255, 255) transparent transparent; position: relative; top: 10px; z-index: 1;">
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="border-width: 11px; border-style: solid; border-color: transparent rgb(215, 215, 215) transparent transparent; position: relative; top: -11px; z-index: 0;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="background-color: rgb(255, 255, 255); border: 1px solid rgb(215, 215, 215); box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 4px; border-radius: 4px; left: -10000px; top: -10000px; z-index: -2147483648; position: absolute; transition: opacity 0.15s ease-out 0s; opacity: 0; visibility: hidden;"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div style="position: relative; z-index: 1;"><iframe src="Just%20a%20moment_files/hcaptcha_004.html"
|
||||||
|
title="Main content of the hCaptcha challenge" scrolling="no"
|
||||||
|
style="border: 0px none; z-index: 2000000000; position: relative;" frameborder="0"></iframe></div>
|
||||||
|
<div
|
||||||
|
style="width: 100%; height: 100%; position: fixed; pointer-events: none; top: 0px; left: 0px; z-index: 0; background-color: rgb(255, 255, 255); opacity: 0.05;">
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="border-width: 11px; position: absolute; pointer-events: none; margin-top: -11px; z-index: 1; right: 100%;">
|
||||||
|
<div
|
||||||
|
style="border-width: 10px; border-style: solid; border-color: transparent rgb(255, 255, 255) transparent transparent; position: relative; top: 10px; z-index: 1;">
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="border-width: 11px; border-style: solid; border-color: transparent rgb(215, 215, 215) transparent transparent; position: relative; top: -11px; z-index: 0;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
170
html_samples/cloudflare_captcha_norobot_v1.html
Normal file
170
html_samples/cloudflare_captcha_norobot_v1.html
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en-US">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Just a moment...</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||||
|
<meta name="robots" content="noindex,nofollow">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<link href="Just%20a%20moment2_files/cf-errors.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
window._cf_chl_opt = {
|
||||||
|
cvId: '2',
|
||||||
|
cType: 'managed',
|
||||||
|
cNounce: '94250',
|
||||||
|
cRay: '732fc1c74f757330',
|
||||||
|
cHash: '8c4978fa93c1751',
|
||||||
|
cUPMDTk: "\/search?q=2022&__cf_chl_tk=6E3KpS5eCzuCMJG64ch2shvOMHdwQ8ioliqACpoQqM8-1659201542-0-gaNycGzNCeU",
|
||||||
|
cFPWv: 'g',
|
||||||
|
cTTimeMs: '1000',
|
||||||
|
cTplV: 2,
|
||||||
|
cRq: {
|
||||||
|
ru: 'aHR0cHM6Ly8wbWFnbmV0LmNvbS9zZWFyY2g/cT0yMDIy',
|
||||||
|
ra: 'TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0OyBydjoxMDUuMCkgR2Vja28vMjAxMDAxMDEgRmlyZWZveC8xMDUuMA==',
|
||||||
|
rm: 'R0VU',
|
||||||
|
d: 'C4CtJo9JDMtUWZ0r+/s2CwjYdSTdqGYK3qFo1OXpvSc9v7/3d5QuMwmvG3e5oV1BpjlQb8eJJ23gVRxavjw/gpPp1brmKoHuvcJEmAP3Sof38vqcpF91/9NHe3JbmCM2xshiGvJdbpJXb5wXdYKYPMqy7NUHL1VU4hupa3Da3tBq9zyuMa1NcZaiyeE6piSl7n96m+VziRdwyG+SBUldIG/Fsv9J1yl+Gj19wbX1XEneMXChcClGgRrSe1MTd9thLkq2NGFqROnsUmpA8b+2Eqi+IPYQfkPcydWkHmJqQixN9ZFTIBChIC60hGHOQ7O354ju65tVGAhB/nBRREpdqvwoYzgufgg83+dbPHVdQasiuLRHvftOtHhS5/iaBOVoEBH+rElTSk/OYjU2Yh6gkQj0FjkbebEBptFeVAxgqoYZljOrhamWYYZ14tOKeonzc1rz/FXNTM5qVtrWCwAlt9SsXDjM/GYXZMTbOdNLnLZGlLNQCx+l6hMC0OQC45sWFzZECljbjXwiYfodKobeqe11lUXnskj8AN5Qc7O8OqtALsxoNCLZ7ou+ORY0lauremeuu3U3WqadgSGFGA+TZZw2VcCA3BIUKCGlsNLBlJ8wQS2UAGJfGLOVuhErmtsM',
|
||||||
|
t: 'MTY1OTIwMTU0Mi4yOTUwMDA=',
|
||||||
|
m: 'eWHHJ28v6yOyvSePVqcdyHxAYkkc3xq3VJ8YiDCk5nk=',
|
||||||
|
i1: 'M3dMvem+HcwSbNQrJbaYdQ==',
|
||||||
|
i2: 'ebY327qYCu6NZKHSQXkbaQ==',
|
||||||
|
zh: 'qP4bnGc6j96JlnjNSE7HmQci3S9L50bHFtm4bQRjjKU=',
|
||||||
|
uh: 'SK3PXNkeRzZtkRARhJpbmZpCIiWQw6+5gpOE7vojWx4=',
|
||||||
|
hh: 'azXzJl8Ou22g0nN/9idVUoB9EqZ7fLmkSdDRHM3Lkmw=',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window._cf_chl_enter = function () { window._cf_chl_opt.p = 1 };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="Just%20a%20moment2_files/v1.js"></script>
|
||||||
|
<script type="text/javascript" src="Just%20a%20moment2_files/api.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="no-js">
|
||||||
|
|
||||||
|
<div class="privacy-pass">
|
||||||
|
<a rel="noopener noreferrer" href="https://addons.mozilla.org/en-US/firefox/addon/privacy-pass/"
|
||||||
|
target="_blank">
|
||||||
|
Privacy Pass
|
||||||
|
<span class="privacy-pass-icon-wrapper">
|
||||||
|
<div class="privacy-pass-icon"></div>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-wrapper" role="main">
|
||||||
|
<div class="main-content">
|
||||||
|
<h1 class="zone-name-title h1">
|
||||||
|
<img class="heading-favicon" src="Just%20a%20moment2_files/favicon.ico"
|
||||||
|
onerror="this.onerror=null;this.parentNode.removeChild(this)">
|
||||||
|
0MAGNET.COM
|
||||||
|
</h1>
|
||||||
|
<h2 class="h2" id="cf-challenge-running">
|
||||||
|
Checking if the site connection is secure
|
||||||
|
</h2>
|
||||||
|
<div id="cf-challenge-stage" style="display: block;">
|
||||||
|
<div id="cf-norobot-container" style="display: flex;"><input type="button" value="Verify you are human"
|
||||||
|
class="big-button pow-button" style="cursor: pointer;"></div>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-spinner" class="spacer loading-spinner" style="display: none; visibility: hidden;">
|
||||||
|
<div class="lds-ring">
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<noscript>
|
||||||
|
<div id="cf-challenge-error-title">
|
||||||
|
<div class="h2">
|
||||||
|
<span class="icon-wrapper">
|
||||||
|
<div class="heading-icon warning-icon"></div>
|
||||||
|
</span>
|
||||||
|
<span id="cf-challenge-error-text">
|
||||||
|
Enable JavaScript and cookies to continue
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<div
|
||||||
|
style="display:none;background-image:url('/cdn-cgi/images/trace/captcha/nojs/transparent.gif?ray=732fc1c74f757330')">
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-body-text" class="core-msg spacer">
|
||||||
|
0magnet.com needs to review the security of your connection before
|
||||||
|
proceeding.
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-fact-wrapper" style="display: block; visibility: visible;" class="fact spacer hidden">
|
||||||
|
<span class="fact-title">Did you know</span> <span id="cf-challenge-fact" class="body-text">botnets can
|
||||||
|
be used to shutdown popular websites?</span>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-explainer-expandable" class="hidden expandable body-text spacer"
|
||||||
|
style="display: block; visibility: visible;">
|
||||||
|
<div class="expandable-title" id="cf-challenge-explainer-summary"><button class="expandable-summary-btn"
|
||||||
|
id="cf-challenge-explainer-btn" type="button"> Why am I seeing this page? <span
|
||||||
|
class="caret-icon-wrapper">
|
||||||
|
<div class="caret-icon"></div>
|
||||||
|
</span> </button> </div>
|
||||||
|
<div class="expandable-details" id="cf-challenge-explainer-details">
|
||||||
|
Requests from malicious bots can pose as legitimate traffic.
|
||||||
|
Occasionally, you may see this page while the site ensures that the
|
||||||
|
connection is secure.</div>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-success" style="display: none;">
|
||||||
|
<div class="h2"><span class="icon-wrapper"><img class="heading-icon" alt="Success icon"
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAANlBMVEUAAAAxMTEwMDAxMTExMTEwMDAwMDAwMDAxMTExMTExMTEwMDAwMDAxMTExMTEwMDAwMDAxMTHB9N+uAAAAEXRSTlMA3zDvfyBAEJC/n3BQz69gX7VMkcMAAAGySURBVEjHnZZbFoMgDEQJiDzVuv/NtgbtFGuQ4/zUKpeMIQbUhXSKE5l1XSn4pFWHRm/WShT1HRLWC01LGxFEVkCc30eYkLJ1Sjk9pvkw690VY6k8DWP9OM9yMG0Koi+mi8XA36NXmW0UXra4eJ3iwHfrfXVlgL0NqqGBHdqfeQhMmyJ48WDuKP81h3+SMPeRKkJcSXiLUK4XTHCjESOnz1VUXQoc6lgi2x4cI5aTQ201Mt8wHysI5fc05M5c81uZEtHcMKhxZ7iYEty1GfhLvGKpm+EYkdGxm1F5axmcB93DoORIbXfdN7f+hlFuyxtDP+sxtBnF43cIYwaZAWRgzxIoiXEMESoPlMhwLRDXeK772CAzXEdBRV7cmnoVBp0OSlyGidEzJTFq5hhcsA5388oSGM6b5p+qjpZrBlMS9xj4AwXmz108ukU1IomM3ceiW0CDwHCqp1NjAqXlFrbga+xuloQJ+tuyfbIBPNpqnmxqT7dPaOnZqBfhSBCteJAxWj58zLk2xgg+SPGYM6dRO6WczSnIxxwEExRaO+UyCUhbOp7CGQ+kxSUfNtLQFC+Po29vvy7jj4y0yAAAAABJRU5ErkJggg=="></span>Connection
|
||||||
|
is secure</div>
|
||||||
|
<div class="core-msg spacer">Proceeding...</div>
|
||||||
|
</div>
|
||||||
|
<form id="challenge-form"
|
||||||
|
action="/search?q=2022&__cf_chl_f_tk=6E3KpS5eCzuCMJG64ch2shvOMHdwQ8ioliqACpoQqM8-1659201542-0-gaNycGzNCeU"
|
||||||
|
method="POST" enctype="application/x-www-form-urlencoded">
|
||||||
|
<input type="hidden" name="md"
|
||||||
|
value="UPeuijc1TS5ZQ21GIY6wjg6HHN_jWKH9sqolcSJABwg-1659201542-0-AR_ZxgiwVB4GwEgAjllIrmnGAumHNwuvfpFBddySYLh6CWexrUnxVYlX_wlB19Yndm45fs-KngMxbYB4dEOuf4MOJ_yL_BsNG3_cIPybV0bNn9WQXecJg3FfFrIBuMFIappZOX4hdDjLtRo9f4JsVsU6FzD9sUoKJRd4BTkjTAm25yFbqmPgV15XZhnJ5HRux044u0IIOVZCwTTzgRLCqToVb-OfiuUcHBzt4W7_wNlF1ObUi2oEr00DA1zZvzzY2KnXdZVN8m2OaNY_f2zkk9uDlLQRob_Ti6MHPNDr4eRkyMqZMZ1XDCxe-9lBkcEfpqtg6_4yac9ZiIEoNdJnJVE6cuNzb59DcBooXAq3IWp6fK4y4UIBStjqOXk4bxQb5yt1COfdPuQ9iLE_7yYOPG_t7n5I-4mjwvG7_U337A17oeEemXHfJkGC88Vm3SQdEHiW96VJuOA_X-rb7p3iOMlLYB5DKJ5DaBoPnP86uAWhoHWE6nrVzeAxeQ1y0uBHYPioJba5Kn9d-e2HsTMuAi7ZgSKuk90ApclIiW3owI4bLc4wxO5cu3ZIz7sZfbdvIKDhf9ESZhpQrITU_4Hgqjz0s3lt-MVeNP_0bz31XSeA--pdiulzUpQWLx1jhC4s7Av6STUb9bmbHpE41283KbbpuzBbmHN1UczNiaaquYZiEXRHKYyEMhKD782nWTJwQA">
|
||||||
|
<input type="hidden" name="r"
|
||||||
|
value="i1ShtnCs9Zs8QexeFnp6EFtrWs3WbGEVQGXbVfYwpRI-1659201542-0-AbDM6G9qkbgoH+BqDdr1tzCDHr/DU9Sdxelapvp2/FZN6VqYfpDkJGv+HxhBQng6aVktcEobxp2ouOxJZxPQrR6tVFIhOW6uPOAdy5kh2BBJWUHfER13aq8LQ86fvDyRh3AThEHj6bgs2udacfvOrDrHT2j/KHBPePlGKbh8rzDTJBKw0ejUleHk8eKX/BQ1bVULgxT+ZZY721lyn2wrjsde1j1OAsiiCDkVvQ4Rs+Bas7UApD5HeWzyrCu2VFk/Qf+Rk+6spM+StYenQUAKXXrekJoIeNxPf/W9ZRsJfwUoY0JUK2thOWiwQOtw21nVDpiCFB9nhhOsmBzBoRQGjckZyu/O5U7jMIFdS9ThCFC0Kffg0MEr5xTkmgw+CNSwN7AlI9v3GS2XdTFOPXe29b68fZXzYfbm2CjqYhmxomZjCGTAmkzXWaVnMOs9Vl/8VurCUEu8SAt5k9Za/vFrEurX1edXNCviVuTOBSLHjqBiLui9FbufzGLq6BaHYi3WIFA1nMkoxduxbErP+Eqyi8UNvzvmEqUbj2COalXcQzkbHkyyLo33MNHZEi1zhhHjwCm1lp6mm4BRe60kRgTHb8X7oxBpY4vEcMz4jQQdsW15xBPAjsH8m9cj1H2ujpd7kfo8JGTyZ7FcoxOzGOuZr8XRpGkH72HaWYz7M+GIb3BBZ1v2Za7sSrzinNLFjHCCVXq68MqOmZ6RhgeexGoKJzcMHsHvgGXB8CisyyNTtA3OQOujybNUnNzlW7vJ/wDreTHkko6jQ/Lm/X2GnLg85BIg6IeROzt3eInAYsCaNKpST/h5bvSGCyzRoOW46oO8ZzZrV2FI2rEr0xLTIVWzQ//K2iGOCz58RisCfxWiF2n+fzj/5nE/0cjTPzYP68TM5BxB058EO7ZEFbgqhUji8IR9V2ahy7kI9dUhwd2S4IyjL+O6hCNPwjpRohkt93wXUCZDMgNoxi1BIylqqtAxYBfodyjFz8mB8GgcqBaCHN3tI0BINENVfvSJwKniYxL73frTX5KEqniT9GdT15o4F7QLf4S1atwYzF6ezJTYgLf6fOWUZKpaFMSRzEsxmZDmOFZeiss8lj7bKS6drOpkaOYzZiSgp5t5VwLKT0yQ+PDWQmqkpZ5WOa9/ayXLyOCunzk1IUO6VkvgFe0P2LZC9XEZUfwAFakYemej8/SZx0EknoPob1il3MMsbfHNAvcvUJK9xDbdAQ7rz34r4D5zO2aPnmYw1yv9K36z78I2dZpjVT9kpiKFwaOTkuSDUDtcmnhKM1XE+goG/C66G6PsChpGKLCeaDw4Rp7BxlumiSGB4Mp/bs8pTz3gez7pSu1oNodr7Tr1wJvCK8T5nVJ5GRO/tQ+Ff2K2s67udoV0CFtKufJyRsGCEv/0u5sArg3uwtwIz1W0JtAVjhe+J2nUihLa0Gqm7AwcCwfhsLHOhMG28V2NAw19iVq8RuMN7A2kGg5PH6bUeilWUxxZvWyDfyRSJZYMQytwAJdt4gQ++Qnl3mcaSk1N3pSiltVUDpfLcYb5gd35m+mKQWtPnIDlJMAtGoBeqROQPLNDg+LYdI/dnJzIOHjI3J+pTWhbAlF7B7NtccZOHmI9Cl3vS6Fpqs5aSPEDoDENTap6JN1kgm5NszMay9tAm66AcKF95W6QhwgQsyRrwScgRaPUtCx9ZJcbav6T/CAulcBB85MjwAd8+HF1g+UZT9VvChZoxh7NzfMoR53pVbxvW6acO8oVN5ITTP8mNAIisRvWi2KVdi4KqaLjYtLFNN8AMzjAC0vBIaFyGZlIbFsB44MRiMufD64b/66dqeC0l0WrUlUG/DgrnSQr6lgK2gONJKPQZGXoaK0Ga8O8xMOkaFLNaqH5UH5KpHvIQ8nwhuXk/MS/7Gdp1W02OEB4l0hhKFytgWdo9QmCquSatvOjuFyRPa6tV8ceGmuDnQw22bJM9BwzdKlHn/2/mHjCz7gcEA3Hb/CbeP8V8mF1mc5R8HEEdz/rx+BTESmGiRivv+WQYpRKNh77iqbYvCvkduK4b3UErNbvcS10aTt8zDFF/oIwjDpsniJsrIUcC0FdQRs2dqPIfkoSHvs7YGmOjx9QThCAiTkPKUE9C5C4YPY4CWRV3nYAFJrTq0F047PkzDYm0AJMCahWK7Vq/Ra3l3nRHu9yI+P0HiruUbkzLgiEJYnAuUtxvpC/Vj0uhr+A0R9Obs1MHkwtDuMs/ETh3ZymeFtWLj70StkslJxTzKGimZSsqQXRFYGHY6CHqHwIXGrArYNjTty48VIfbfaEu58KQp6roOdFmx90AcK2lV0V5UdyuzDJeH/V5ERAmxWLrXQKWgiDrY4ZqecnRk5XEAVMq/ChPts9gR7xsQK5WsHtQNKLfltkL8YvAoS+jZvxzfUUBg99YSC4J/HzQS+FQAnkDxCgeroahXysNN1bgDASXOrn3NsC3LYpUiZ2AVTLPkj1roR9r65O">
|
||||||
|
|
||||||
|
<span style="display: none;"><span style="display: none;" class="text-gray-600"
|
||||||
|
data-translate="error">error code: 1020</span></span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var trkjs = document.createElement('img');
|
||||||
|
trkjs.setAttribute('src', '/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=732fc1c74f757330');
|
||||||
|
trkjs.setAttribute('style', 'display: none');
|
||||||
|
document.body.appendChild(trkjs);
|
||||||
|
var cpo = document.createElement('script');
|
||||||
|
cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=732fc1c74f757330';
|
||||||
|
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
|
||||||
|
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
|
||||||
|
history.replaceState(null, null, "\/search?q=2022&__cf_chl_rt_tk=6E3KpS5eCzuCMJG64ch2shvOMHdwQ8ioliqACpoQqM8-1659201542-0-gaNycGzNCeU" + window._cf_chl_opt.cOgUHash);
|
||||||
|
cpo.onload = function () {
|
||||||
|
history.replaceState(null, null, ogU);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(cpo);
|
||||||
|
}());
|
||||||
|
</script><img src="Just%20a%20moment2_files/transparent.gif" style="display: none">
|
||||||
|
|
||||||
|
<div class="footer" role="contentinfo">
|
||||||
|
<div class="footer-inner">
|
||||||
|
<div class="clearfix diagnostic-wrapper">
|
||||||
|
<div class="ray-id">Ray ID: <code>732fc1c74f757330</code></div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
Performance & security by
|
||||||
|
<a rel="noopener noreferrer" href="https://www.cloudflare.com/" target="_blank">Cloudflare</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
120
html_samples/cloudflare_init_v1.html
Normal file
120
html_samples/cloudflare_init_v1.html
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en-US">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Just a moment...</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
||||||
|
<meta name="robots" content="noindex,nofollow" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<link href="/cdn-cgi/styles/cf-errors.css" rel="stylesheet" />
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
window._cf_chl_opt = {
|
||||||
|
cvId: '2',
|
||||||
|
cType: 'managed',
|
||||||
|
cNounce: '46449',
|
||||||
|
cRay: '732fd3bc9c1d72de',
|
||||||
|
cHash: '8838fcad2a7f56c',
|
||||||
|
cUPMDTk: "\/search?q=2022&__cf_chl_tk=y4XnN88eYeUiXmFkQeqEipve1VuK0jJA.G4Hz6xztsM-1659202277-0-gaNycGzNBz0",
|
||||||
|
cFPWv: 'g',
|
||||||
|
cTTimeMs: '1000',
|
||||||
|
cTplV: 2,
|
||||||
|
cRq: {
|
||||||
|
ru: 'aHR0cHM6Ly8wbWFnbmV0LmNvbS9zZWFyY2g/cT0yMDIy',
|
||||||
|
ra: 'Y3VybC83Ljg0LjA=',
|
||||||
|
rm: 'R0VU',
|
||||||
|
d: '+SdFLvm4kJf8Z9BVci1ZbUOY6ab/Dm5Zzyb0IvscIzmY9PnAAcvPfJ/3TD9YJViBxB/ArnbCQrOUfbSkq4odyaZmW19gm+exRuL8Z3POm1ABs7y6jwMshM19q4Gr3eFY/MUO/IYWuyA2F9q94hRCI6ZNb7dLEh9yh6hORbKRd62pdn59h1xCx8tNdKDtP7VXPXo85nYmJJPLOdXTnII+YxZ03a4isAmBHbi+lGoQN/bCV0K006VmpfPElAfAO9jm45o7pc1NgPQhZSKWpTyI/nHMueH6wacPREzN5RtREoQfKuwYpV++Gq56qr5bAe/SKeF+rI0x7OSqC4HQvrNwbA+kHZzaxgOKeiMFjDxmro/GyC/+sxeZmrxnSIAh4BScjPxEl1FLLkg/6D0JH6HmxoT8N/Jgpi9447Am4WeX+WQxJ9+uDs5WrFIahx7pWrgcZUTRPh+UCu3allJ2Q3cAfwK6BclhES/HhBBbJv0pnR1R2RfKDM/gr1MpLuhaK4mFEO/kSyNUjOnCjOfd+5d7Qb0DZn7sHpF2SVc+zNv5OWSvCRDUcNHjIOV6fq0datVyVWmxD6unPS0MMUFO+ZZNiB4ionrhVCiLrb2FjPQ8tzyCqXg+tnV7WtZ0h4+JuK3rxcaQ8PQy60/As8dKHqVTnw==',
|
||||||
|
t: 'MTY1OTIwMjI3Ny44NjMwMDA=',
|
||||||
|
m: 'zvAOPvfoONkW1BzH+jMnKOPtDpPpZijRP52DVDWH+i8=',
|
||||||
|
i1: 'dDlQDNhOEuHzFEPo/etoAA==',
|
||||||
|
i2: '+LTK9hchBRjTTQk1WQU1Vw==',
|
||||||
|
zh: 'qP4bnGc6j96JlnjNSE7HmQci3S9L50bHFtm4bQRjjKU=',
|
||||||
|
uh: 'IdIU2i4FhVxxcYhzSFWdjoBuQm7qnyVK65JGofJuWV4=',
|
||||||
|
hh: 'azXzJl8Ou22g0nN/9idVUoB9EqZ7fLmkSdDRHM3Lkmw=',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window._cf_chl_enter = function () { window._cf_chl_opt.p = 1 };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="no-js">
|
||||||
|
|
||||||
|
<div class="main-wrapper" role="main">
|
||||||
|
<div class="main-content">
|
||||||
|
<h1 class="zone-name-title h1">
|
||||||
|
<img class="heading-favicon" src="/favicon.ico"
|
||||||
|
onerror="this.onerror=null;this.parentNode.removeChild(this)" />
|
||||||
|
0MAGNET.COM
|
||||||
|
</h1>
|
||||||
|
<h2 class="h2" id="cf-challenge-running">
|
||||||
|
Checking if the site connection is secure
|
||||||
|
</h2>
|
||||||
|
<noscript>
|
||||||
|
<div id="cf-challenge-error-title">
|
||||||
|
<div class="h2">
|
||||||
|
<span class="icon-wrapper">
|
||||||
|
<div class="heading-icon warning-icon"></div>
|
||||||
|
</span>
|
||||||
|
<span id="cf-challenge-error-text">
|
||||||
|
Enable JavaScript and cookies to continue
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<div
|
||||||
|
style="display:none;background-image:url('/cdn-cgi/images/trace/captcha/nojs/transparent.gif?ray=732fd3bc9c1d72de')">
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-body-text" class="core-msg spacer">
|
||||||
|
0magnet.com needs to review the security of your connection before
|
||||||
|
proceeding.
|
||||||
|
</div>
|
||||||
|
<form id="challenge-form"
|
||||||
|
action="/search?q=2022&__cf_chl_f_tk=y4XnN88eYeUiXmFkQeqEipve1VuK0jJA.G4Hz6xztsM-1659202277-0-gaNycGzNBz0"
|
||||||
|
method="POST" enctype="application/x-www-form-urlencoded">
|
||||||
|
<input type="hidden" name="md"
|
||||||
|
value="DpGhFnuVRfDhqsQNASrgdT4WiiJ8m6lqTIs03.l6RLc-1659202277-0-AfUEAk9DsJ4rmpVI_Al7-eogy2CmM3YgWe4-31iw0oG2CcDIbYvauEW2IvK9m27_gq1FvdH-UPaGHR0q6Q2haXlX4pgmQK5rlQUSEd5HquGdtWMasHWqL_Q_TZGdOKz30bE2FEk8wLHRErHJRJloDRj0tiG8MreT2La_GLvovNK1XbMXDxFZT2Cc-DThBvxbgbDffw3okYfdl1ECXhLw9G6L4o8xgLsz3QZQG3dNZNhm5n4mf55-BBsFDzDTEN1_1BgORVw3mtbsodedktcACsVBCRupyBpTev9MML1jHzk06ZT9dhcCP4zXvsMS4-gG212LFu79Cpl0MHifKvPk0DTJQja1ulaT4gVuIvmLPihPh1IYMGbEcdX4MFH0Wu_RL6UPINE6esf-oAx8-imKhKITB_R4974rpq9XJk65Kf9R6AJhu072CyOqW1YcmYMkUCqFjdZnRyNgHRT2Q5bMEJ8fv0DwfFV6ynG7n6JGMd_pEnZp0nEvjWXpK6Ft8ZZGOXtFMfmW4vNgFhs6xJ1wnaJWuLXae3V6gTZYxMkeIsyMzlvRSzYBz_rgRBNkvvAwbNvOZ369tKbaElS39hOI1WTaoOsnY2d0Z4mDe4AVbSs3fVJGikzZSa3Ctr1RnqqOztVIRYL1Q7IYRJ02P6egL7sn7RniJ6znNAoPhaWJLYzynWXeQF5YO5U0Zf779qkm3A" />
|
||||||
|
<input type="hidden" name="r"
|
||||||
|
value="QJznOl.RWpNvkdG1Pf6TAzaNhRIFpH8DJ0w1yAuwRLw-1659202277-0-AcOBapBisncM3qf1RYdkTNlIXCth/TmoAMnk3vJozFlG8/vYeLPpjG389mhQu01aSlpJqFWn0VQf9c/7w3yh85jHmrpaxJtpxTiSL9k+AWm61kE6DkHgJBl5jUc7gu4W3oHdmP4FyOUzhbBpIkOAntSkVJJmgu6SaIE3I9fRAFu7bPxBveT8zZGyVUJSPKpwx/w4rNPzs2VnCeEVL1eOdbLInHYR1kqC8M4JyBynwdVXxIX+j5o/rTrNK8E/W4UZMhuWqIaOnX7FzmceglyBSjDqJFLCt0TOhc66m82Y25Obi8Gvsqn34bjwPA2G8qOvgrHA2RFH6lEQFSdGMzLrF4qU5P9j9FzU1CPSTfGtkKbsMnGcMrtzmyQ7LdMIfghYvnCBXTi82iIzaSwzY3sEnW9KZs24Akxu/AV1E03sqW1CAA1UCRURpX4GKXvD6UYpSgc6++q8naLdRozkLP81T/CvHyIRdQx8vylmVN9u/rPvMbW1jWtniDmuAjBQDUd058YH+IRmm4lREG5JN2yeX083h/BG6tssEQVdTcIgwZRNDB+kK8vtOmywmo5qTAX1VE/sgfPCw5+3Xxu+hhZON3C7VGfrCQI5ZSb6+YvBLXmO26Nlp3fSOyeBwZy3pVuGwv/TrEo+e8USIlIs1T6MQJYQeX/4vOdy89npo6KBqY23giTFDh8EMZo//93hfBsRUbHrY/It6kp42qzsnWTjbkyiqd1zBSpQhuMyuMPeKpQ63oVI2tlGyioLg3HcfhbHQcdpUAWDn8lZ4+GTFVMix+20fGbErkVeBs7WvFSLlZ1YtYpCXrgVaomj7WCr8Icb7ASXKfvEuqC1ZnZgn6Lb6x3dUBGiDtnSFnixHFElIF6nPedVIV0+TxccjlV/LJeyNM58GHtRo4NcmIo1a6kN3vzPAjTUhgDJe4aYP6oVKCRNDcrHlGlLubu6XuIvBFM5Sq401xxahOe3VP2u7JovkzXwfl+yUxQOYaoq1LR+wnDhXgVbBNbM2QfIhez578zu2TN5bu5H14UXZ1E78KA6Op9b/PUgA1AsgTJVRk4M6OQSpa5wRIKkXzxpGIRz6+YBxSjIaX2I220GH4s6Te4CBpq77g6V4CVIkEvqZwbN9hIoAoljWVbEEdb3WmYZqoPxN/8ZIjU7uwQUyDgnCOlc7Z52TgG6nVvj7RVyxv5ugskW+fcOI12o35iYNNpXTh1boHyn7nlPG7wtSsl9UlTss27nd04AIzbH0qyX3kn77yPsobMDYUJ3IGhOujV8Cg08XHFIlYSYGPbqqpog+CuuWtzvwyk5mmHXkJNPyFEZL/irApJbatpGNqgGNnQL+5KYp+/U8/kROLTOWa8tG5609MF+wdrScsfPT9eE+HYh7tEFURnwm8kJtdAadcxYjzO60PFcUI1R5SMGHRflAnpY2gvAzbsSssk1WIF+6eHSe6FLHMXCHMp0w1XkNKpny5Ce3YTKhJ4TRg7HfN1pvet2Duj4G04A328uYUppPlU7Spz0fj5N/FHJf3sPaqJC8jn74L0mT92ecGaxS3ZGvytw51ulA00wgzfZDWL4pirzgYVjUQTqVl9FzWYua4Vk4l3BX0opWKA4FloLTP3ekrvmO/zkztMBV4fvK+F8JIOzLOs4AuoCv8uXl7Ny9wLQI3a0hJAdbXJpI3WV/iuV7da4fQao2Z2HiatQh3ZtdLqWmGtqQlcVtsBrac82eo7mKAfwltTfLlX9Drtp4ohwoFe0Upm+YsfY6DK7zHrk3k9GN7gm6cMi1neNFaqWZR9s8ABDBg==" />
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var trkjs = document.createElement('img');
|
||||||
|
trkjs.setAttribute('src', '/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=732fd3bc9c1d72de');
|
||||||
|
trkjs.setAttribute('style', 'display: none');
|
||||||
|
document.body.appendChild(trkjs);
|
||||||
|
var cpo = document.createElement('script');
|
||||||
|
cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=732fd3bc9c1d72de';
|
||||||
|
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
|
||||||
|
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
|
||||||
|
history.replaceState(null, null, "\/search?q=2022&__cf_chl_rt_tk=y4XnN88eYeUiXmFkQeqEipve1VuK0jJA.G4Hz6xztsM-1659202277-0-gaNycGzNBz0" + window._cf_chl_opt.cOgUHash);
|
||||||
|
cpo.onload = function () {
|
||||||
|
history.replaceState(null, null, ogU);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(cpo);
|
||||||
|
}());
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="footer" role="contentinfo">
|
||||||
|
<div class="footer-inner">
|
||||||
|
<div class="clearfix diagnostic-wrapper">
|
||||||
|
<div class="ray-id">Ray ID: <code>732fd3bc9c1d72de</code></div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
Performance & security by
|
||||||
|
<a rel="noopener noreferrer" href="https://www.cloudflare.com" target="_blank">Cloudflare</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
167
html_samples/cloudflare_spinner_v1.html
Normal file
167
html_samples/cloudflare_spinner_v1.html
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
<html lang="en-US">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Just a moment...</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||||
|
<meta name="robots" content="noindex,nofollow">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<link href="/cdn-cgi/styles/cf-errors.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
window._cf_chl_opt = {
|
||||||
|
cvId: '2',
|
||||||
|
cType: 'managed',
|
||||||
|
cNounce: '52875',
|
||||||
|
cRay: '732fa2449b567521',
|
||||||
|
cHash: '79cce74ebb92671',
|
||||||
|
cUPMDTk: "\/search?q=2022&__cf_chl_tk=1qWQAgl8.irfEoDb73Rb0pUm1SXbis3ZamDAIoTcPks-1659200251-0-gaNycGzNCFE",
|
||||||
|
cFPWv: 'g',
|
||||||
|
cTTimeMs: '1000',
|
||||||
|
cTplV: 2,
|
||||||
|
cRq: {
|
||||||
|
ru: 'aHR0cHM6Ly8wbWFnbmV0LmNvbS9zZWFyY2g/cT0yMDIy',
|
||||||
|
ra: 'TW96aWxsYS81LjAgKFgxMTsgTGludXggeDg2XzY0KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvMTAzLjAuNTA2MC4xMzQgU2FmYXJpLzUzNy4zNg==',
|
||||||
|
rm: 'R0VU',
|
||||||
|
d: 'UfK0k9mFeKGEdqoWAUIbk3OXbXe9DOHoYXdKLPyxbICSIQBS4GSNYar0DtbPI7+UQ7UeBZ2XCdQinvgH0pgzJCF1qB0nkXtu0qlLk6EwkrGAKD/pMGFFQF2EaCw3m00/xoRCDgLZRl/wUkRGz3HUOkTuPeKgZjsFyPoPv7MbYSMUtH7QU6ruIh+O3hvDOT2oA/BOKbRMSTnFedTIXADXL6GE8ZyNZ33wJlef5KzT0MHlN+3eZTAt6urCvJaY3MdTXKVye6fwyjqGEksaJ6B85vwrifLTYEU4/bORwXx8mTQTqjo3kh1rATlmthQwBpcQtWXmgDUcJ5gPrOk1fzhqrhO4b++HiIx3P5YZ9Ko2D0NNWeg1AYIwDjh9rZg5m0MmCXh1VqXDbnpseQW1vPkkZAADxyvLf/eEc1o2EpYGpK+qSpMZ4RcngnU0o8A2nS+j/CNsid0315OrYVyOIZcw6L3ovu6yfAAAALyOmg5ctXCqjzRthoibUb58u+myxOtfX1ew9IzNq8Z6t6RlomjR7Iy/7BJiJQNCF98dllNbODHz//TymlI1m8D9w+CYlZFIpiWJVH1M4h+tabH5YrqDVbkJgY6yVAfnr/NI6d6NHrhN+eSW30jkvAmZ6JRMhVWW',
|
||||||
|
t: 'MTY1OTIwMDI1MS42MjAwMDA=',
|
||||||
|
m: '/e8nTBb03IHZzN/DSkoHPRu0Ndm3ynYs8g6ZC+VxHcc=',
|
||||||
|
i1: 'tx+ntPfeE2Gv81s52vIOlA==',
|
||||||
|
i2: 'fpw8a/EO+Fo2t/ZiNKxEcg==',
|
||||||
|
zh: 'qP4bnGc6j96JlnjNSE7HmQci3S9L50bHFtm4bQRjjKU=',
|
||||||
|
uh: 'Eex9UQDjphKtV6LyVQ95F/MC5kBA3Rj4lC6CudiU3Vs=',
|
||||||
|
hh: 'azXzJl8Ou22g0nN/9idVUoB9EqZ7fLmkSdDRHM3Lkmw=',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window._cf_chl_enter = function () { window._cf_chl_opt.p = 1 };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=732fa2449b567521"></script>
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="https://cloudflare.hcaptcha.com/1/api.js?endpoint=https%3A%2F%2Fcloudflare.hcaptcha.com&assethost=https%3A%2F%2Fcf-assets.hcaptcha.com&imghost=https%3A%2F%2Fcf-imgs.hcaptcha.com&render=explicit&recaptchacompat=off&onload=_cf_chl_hload"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="no-js">
|
||||||
|
|
||||||
|
<div class="privacy-pass">
|
||||||
|
<a rel="noopener noreferrer"
|
||||||
|
href="https://chrome.google.com/webstore/detail/privacy-pass/ajhmfdgkijocedmfjonnpjfojldioehi"
|
||||||
|
target="_blank">
|
||||||
|
Privacy Pass
|
||||||
|
<span class="privacy-pass-icon-wrapper">
|
||||||
|
<div class="privacy-pass-icon"></div>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-wrapper" role="main">
|
||||||
|
<div class="main-content">
|
||||||
|
<h1 class="zone-name-title h1">
|
||||||
|
<img class="heading-favicon" src="/favicon.ico"
|
||||||
|
onerror="this.onerror=null;this.parentNode.removeChild(this)">
|
||||||
|
0MAGNET.COM
|
||||||
|
</h1>
|
||||||
|
<h2 class="h2" id="cf-challenge-running">
|
||||||
|
Checking if the site connection is secure
|
||||||
|
</h2>
|
||||||
|
<div id="cf-challenge-stage" style="display: none;"></div>
|
||||||
|
<div id="cf-challenge-spinner" class="spacer loading-spinner" style="display: block; visibility: visible;">
|
||||||
|
<div class="lds-ring">
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<noscript>
|
||||||
|
<div id="cf-challenge-error-title">
|
||||||
|
<div class="h2">
|
||||||
|
<span class="icon-wrapper">
|
||||||
|
<div class="heading-icon warning-icon"></div>
|
||||||
|
</span>
|
||||||
|
<span id="cf-challenge-error-text">
|
||||||
|
Enable JavaScript and cookies to continue
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</noscript>
|
||||||
|
<div
|
||||||
|
style="display:none;background-image:url('/cdn-cgi/images/trace/captcha/nojs/transparent.gif?ray=732fa2449b567521')">
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-body-text" class="core-msg spacer">
|
||||||
|
0magnet.com needs to review the security of your connection before
|
||||||
|
proceeding.
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-fact-wrapper" class="fact spacer hidden" style="display: block; visibility: visible;">
|
||||||
|
<span class="fact-title">Did you know</span> <span id="cf-challenge-fact" class="body-text">bots
|
||||||
|
historically made up nearly 40% of all internet traffic?</span>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-explainer-expandable" class="hidden expandable body-text spacer"
|
||||||
|
style="display: none;">
|
||||||
|
<div class="expandable-title" id="cf-challenge-explainer-summary"><button class="expandable-summary-btn"
|
||||||
|
id="cf-challenge-explainer-btn" type="button"> Why am I seeing this page? <span
|
||||||
|
class="caret-icon-wrapper">
|
||||||
|
<div class="caret-icon"></div>
|
||||||
|
</span> </button> </div>
|
||||||
|
<div class="expandable-details" id="cf-challenge-explainer-details"> Requests from malicious bots can
|
||||||
|
pose as legitimate traffic. Occasionally, you may see this page while the site ensures that the
|
||||||
|
connection is secure.</div>
|
||||||
|
</div>
|
||||||
|
<div id="cf-challenge-success" style="display: none;">
|
||||||
|
<div class="h2"><span class="icon-wrapper"><img class="heading-icon" alt="Success icon"
|
||||||
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAANlBMVEUAAAAxMTEwMDAxMTExMTEwMDAwMDAwMDAxMTExMTExMTEwMDAwMDAxMTExMTEwMDAwMDAxMTHB9N+uAAAAEXRSTlMA3zDvfyBAEJC/n3BQz69gX7VMkcMAAAGySURBVEjHnZZbFoMgDEQJiDzVuv/NtgbtFGuQ4/zUKpeMIQbUhXSKE5l1XSn4pFWHRm/WShT1HRLWC01LGxFEVkCc30eYkLJ1Sjk9pvkw690VY6k8DWP9OM9yMG0Koi+mi8XA36NXmW0UXra4eJ3iwHfrfXVlgL0NqqGBHdqfeQhMmyJ48WDuKP81h3+SMPeRKkJcSXiLUK4XTHCjESOnz1VUXQoc6lgi2x4cI5aTQ201Mt8wHysI5fc05M5c81uZEtHcMKhxZ7iYEty1GfhLvGKpm+EYkdGxm1F5axmcB93DoORIbXfdN7f+hlFuyxtDP+sxtBnF43cIYwaZAWRgzxIoiXEMESoPlMhwLRDXeK772CAzXEdBRV7cmnoVBp0OSlyGidEzJTFq5hhcsA5388oSGM6b5p+qjpZrBlMS9xj4AwXmz108ukU1IomM3ceiW0CDwHCqp1NjAqXlFrbga+xuloQJ+tuyfbIBPNpqnmxqT7dPaOnZqBfhSBCteJAxWj58zLk2xgg+SPGYM6dRO6WczSnIxxwEExRaO+UyCUhbOp7CGQ+kxSUfNtLQFC+Po29vvy7jj4y0yAAAAABJRU5ErkJggg=="></span>Connection
|
||||||
|
is secure</div>
|
||||||
|
<div class="core-msg spacer">Proceeding...</div>
|
||||||
|
</div>
|
||||||
|
<form id="challenge-form"
|
||||||
|
action="/search?q=2022&__cf_chl_f_tk=1qWQAgl8.irfEoDb73Rb0pUm1SXbis3ZamDAIoTcPks-1659200251-0-gaNycGzNCFE"
|
||||||
|
method="POST" enctype="application/x-www-form-urlencoded">
|
||||||
|
<input type="hidden" name="md"
|
||||||
|
value="OghUU_ltYW6I0fpWl7rE4yHBGBPHfpZQIKZRSEpJKjE-1659200251-0-AWB-KR-MabhObmvYa3mR5-xDk3qZVV73547wjnl-QtfPoTxe017AXt4WUskEcVzEIUKC7dsJoiy8ec1NA0fxdnI8X9OfPhtynl00ReWBVZc_3Gba_wigWMmM_9e8PX9vpVDcXpCRbz1BJ5_YLsba9TJM1sp14U9RtIce-tRBB53qoxLxJRz9QFmckEVBvsba4RfoycOvYPMMsfAqSkq13qtsA3Kd6RDB5Rb5-qF8674DsB4AMvd9xu_fBplQqKjOpEtrThCUtw8M2DHY8FUr_owUo1NIS1s6fSBEyHh6ehz9CidJ7zpRwYZFwgz_Pq9i8LmQG_AajozOJJhLp-tox0dptbUZnRNGt3hGQgrNu3jlCfwPC2XVp7xgLvmZoPYrzzrZoi_wErnIvVgyGCw9-sDPblPdvLBUz6uXNreWwThEW6PeRtMXnePO9UwcZmj_2awhwcVSHSLz1t1z22LtVsQ8xNpMbiE7xDvI2D5LNHAPIUC7Wp4AcehWD-fEm0w5jnVTWOmFlVRxtcnYZSMfDSaRUxsZ3hg5B1-ghVMEX6M-r_hAd6pLKNmjIfdl_Nvdm6veQvV-gTFaULbfuhmQQjYEb9G2IptDiNTZs5S7FtmjqVBAA7PmvwBTQwxw86J0cV3v_4pT1Oj8tigwiPny35HMTrKRmRZWaAZudCmWxDZkJIW8Eir7KQ57ba-u9cHh0A">
|
||||||
|
<input type="hidden" name="r"
|
||||||
|
value="q.UUtPBFcFi4IkcVw3l4U_xJJKDIbHJj7xmuB43IIAI-1659200251-0-Aa4lU5RipD+d4of3hcdQ0rVmZ4ulb3siZYKwhm1jGNiA+/9b8IW1HL8k1GrsYEVexDW7ycP5UINQZ1sYJvZBTCQe3lhyGLHdLZ7KdI9RXKEbPx1NUOR/HthCD0Wbo7H41jbAf7l+HhH0zTLjm77/6NpJZHcgfsbBwwubl4R3oLarzPSByV2PVBnkuMyKCYgibriuMUt2iJHoMLx7Cr+Bmjx1KEFCrPYP0t7vgQs2APTylhL7ebP77XB9ndxU6Of3r4eHnTwLIcomFJ3+jqL6pzFaNoXdUBHrv9oZs/33KZjf2NB8cu5KUpAdM2lp3t5oTSQE19fJVroxmf91hcTdele3F2DAeawFGDwncm/Jo725SlyNk4TqsmR+il7DLkS/FTcCNzQe4cQM6DRWdmF9I1OohAl1/uGXYqUJSK1F45n3gec/pyPTQyZI0OLc7sCGYXfn3VPFsGATkg5mxE9rgZIB2b6ID9JggzIlDdYxlQRWecpruu07KOgk3m7g95lyHNZTohqemo4T8Z2MOZECjmXGMAuwvvk4d5sakVHr39kmAY6aSfXrRB+iONCOKkahbumrVmjLsnMvrpTb0DFE5pRAxwANPZKzb6Ikmlvxh7oJIPOB0mG9hDeoc/AJVlvZJV4CrpDLulNjHetAWXMwMptZuYJGEhcDXxmYj0ybntTCU4Y3JJQc5K+7ehSdnluTvMueWfs628854r4PcOONZzsO337j+3lUxrP5vDUCzYD25FNxvs8jGfqRivqHMOq2z9iOs0sHQTlHroLLSt2G7M50yRJBGTfxrIsvLq+ML3e/mRIkYIQxOcp8ugoPoT4c9gex3OyY0cnnA2/9OibQs9kevwf9DSnutMRRcbIXZI0XO6FY07+MykWqUcXygwMHs1vQxhaQ26NFYwolEWfOL7EQpp4GKyN30nL4nPNil/7GsXIr5SC+o55KI0l3AOEYE1jirVx2G0U7Br7SW80Ih4Fn5U/+4qFfW57GAJrpuk9qjFfJehe7wFBu5bHghEGRhKAu0wvpY7UTc9AiacMfP7ujVWi4DIbTCfOzOgVT8E0T6KaUurBppPJflLQE41c8n29ULyKmki9t8lIKvxYmv/3/AauhXFAExh+JrdnaeSDxhJYjWEUDJiaNvnkDCHMxPs/bePhSg4DYRMh4ngcOHCRkkRlDjipUUgeCrwNBY0qu2DIqLZXI1ZMwU+R0nuWnwc5xJuMHtrLkWbziP0FQcGaF0B6SaFIcOLnWG7YjJZFzxjFpvLb8GnZxk7i2YHCDTn0Stq3JDZHCkjJQjaPMmuK+5KYzfaSHcKOcaQbkbyDjn3t/XQX3a7lknngVchIJVsVn8osqgKvOx3aAdCicYKR6QaukrXHhR9uIEbPdoBYqZPKFz0uvVOShsUx2f65CaI8wWMjOBRWxTK1xUPNsetOiyYSvNwjeULaCXPKLi2qv/cZRRbsr3g5ghdHvNTpD/O0/xUgiziev3/9CpNopyr6VzLar9dJ/s++imXY1w1TCRJ2uCI2H70XGBGWxSZdbnfxU+j3zNCL0dBuabwhDd4ZnOZmlFZjGBiOUpsWdRrHd3c+QpwXdxB3QurRwX6J+LhmkqcWsPhP7LlMnN7dr2HUFZ5FS4LASl5AOf8hjCnO06FT8fWLl1eKVVjCugx9w54qjGqOV8A0v/PdWr7Ic0WfriyYbmwn/XnH8t0ri3bqDZsDkfhQMMF9JSWHEdoGD60a7McGDxr4g9s3LZhq5KozgSvyG+RUBPla8g2zB253hR7amWE5WO4IChl7AXmRB89F9u2+AoDIbefseb3pwG7GfkYpSBwmgJ4Ju4LAWoSfBhZSPMQadHZOCg36R11KesUy+NAy9bvD1bE3UMx9e2NbFohu6sXlilpnxINHp0sFEeulreEjWSQreri1eZeKxV2QfKIzWUiMoNdyT0JzM+/brYzddBpO2DrlnK5bEPWgtu0D7d4Kfm+0T7S//Fq+hxf40lSMPP8cBlan6sEd2iWmZ6gW3z43wNbJaPQIUDgb58ELxaEKQN4tOOy75/XXfISNnhG0K8M79a175WUb8v0A=">
|
||||||
|
|
||||||
|
<span style="display: none;"><span class="text-gray-600" data-translate="error">error code:
|
||||||
|
1020</span></span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var trkjs = document.createElement('img');
|
||||||
|
trkjs.setAttribute('src', '/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=732fa2449b567521');
|
||||||
|
trkjs.setAttribute('style', 'display: none');
|
||||||
|
document.body.appendChild(trkjs);
|
||||||
|
var cpo = document.createElement('script');
|
||||||
|
cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/managed/v1?ray=732fa2449b567521';
|
||||||
|
window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;
|
||||||
|
window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, -window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;
|
||||||
|
if (window.history && window.history.replaceState) {
|
||||||
|
var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;
|
||||||
|
history.replaceState(null, null, "\/search?q=2022&__cf_chl_rt_tk=1qWQAgl8.irfEoDb73Rb0pUm1SXbis3ZamDAIoTcPks-1659200251-0-gaNycGzNCFE" + window._cf_chl_opt.cOgUHash);
|
||||||
|
cpo.onload = function () {
|
||||||
|
history.replaceState(null, null, ogU);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(cpo);
|
||||||
|
}());
|
||||||
|
</script><img src="/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=732fa2449b567521" style="display: none">
|
||||||
|
|
||||||
|
<div class="footer" role="contentinfo">
|
||||||
|
<div class="footer-inner">
|
||||||
|
<div class="clearfix diagnostic-wrapper">
|
||||||
|
<div class="ray-id">Ray ID: <code>732fa2449b567521</code></div>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
Performance & security by
|
||||||
|
<a rel="noopener noreferrer" href="https://www.cloudflare.com" target="_blank">Cloudflare</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
// A list of paths to directories that Jest should use to search for files in
|
|
||||||
roots: [
|
|
||||||
"./src/"
|
|
||||||
],
|
|
||||||
// Compile Typescript
|
|
||||||
transform: {
|
|
||||||
'^.+\\.(ts|tsx)$': 'ts-jest'
|
|
||||||
},
|
|
||||||
// Default value for FlareSolverr maxTimeout is 60000
|
|
||||||
testTimeout: 70000
|
|
||||||
}
|
|
||||||
14827
package-lock.json
generated
14827
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
47
package.json
47
package.json
@@ -1,46 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "flaresolverr",
|
"name": "flaresolverr",
|
||||||
"version": "2.0.0",
|
"version": "3.3.21",
|
||||||
"description": "Proxy server to bypass Cloudflare protection.",
|
"description": "Proxy server to bypass Cloudflare protection",
|
||||||
"scripts": {
|
"author": "Diego Heras (ngosang / ngosang@hotmail.es)",
|
||||||
"start": "node ./dist/server.js",
|
"license": "MIT"
|
||||||
"build": "tsc",
|
|
||||||
"dev": "nodemon -e ts --exec ts-node src/server.ts",
|
|
||||||
"package": "node build-binaries.js",
|
|
||||||
"test": "jest --runInBand"
|
|
||||||
},
|
|
||||||
"author": "Diego Heras (ngosang)",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/ngosang/FlareSolverr"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"flaresolverr": "dist/server.js"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"await-timeout": "^1.1.1",
|
|
||||||
"body-parser": "^1.19.0",
|
|
||||||
"console-log-level": "^1.4.1",
|
|
||||||
"express": "^4.17.1",
|
|
||||||
"puppeteer": "^3.3.0",
|
|
||||||
"uuid": "^8.3.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/await-timeout": "^0.3.1",
|
|
||||||
"@types/body-parser": "^1.19.1",
|
|
||||||
"@types/express": "^4.17.13",
|
|
||||||
"@types/jest": "^27.0.2",
|
|
||||||
"@types/node": "^14.17.27",
|
|
||||||
"@types/puppeteer": "^3.0.6",
|
|
||||||
"@types/supertest": "^2.0.11",
|
|
||||||
"@types/uuid": "^8.3.1",
|
|
||||||
"archiver": "^5.3.0",
|
|
||||||
"nodemon": "^2.0.13",
|
|
||||||
"pkg": "^5.3.3",
|
|
||||||
"supertest": "^6.1.6",
|
|
||||||
"ts-jest": "^27.0.7",
|
|
||||||
"ts-node": "^10.3.0",
|
|
||||||
"typescript": "^4.4.4"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
requirements.txt
Normal file
13
requirements.txt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
bottle==0.12.25
|
||||||
|
waitress==2.1.2
|
||||||
|
DrissionPage==4.1.0.0b14
|
||||||
|
func-timeout==4.3.5
|
||||||
|
prometheus-client==0.17.1
|
||||||
|
# required by undetected_chromedriver
|
||||||
|
requests==2.32.3
|
||||||
|
certifi==2024.07.04
|
||||||
|
websockets==11.0.3
|
||||||
|
# only required for linux and macos
|
||||||
|
xvfbwrapper==0.2.9; platform_system != "Windows"
|
||||||
|
# only required for windows
|
||||||
|
pefile==2023.2.7; platform_system == "Windows"
|
||||||
BIN
resources/flaresolverr_logo.ico
Normal file
BIN
resources/flaresolverr_logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
83
src/app.ts
83
src/app.ts
@@ -1,83 +0,0 @@
|
|||||||
import log from './services/log'
|
|
||||||
import {NextFunction, Request, Response} from 'express';
|
|
||||||
import {getUserAgent} from "./services/sessions";
|
|
||||||
import {controllerV1} from "./controllers/v1";
|
|
||||||
|
|
||||||
const express = require('express');
|
|
||||||
const app = express();
|
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
const version: string = 'v' + require('../package.json').version
|
|
||||||
|
|
||||||
// Convert request objects to JSON
|
|
||||||
app.use(bodyParser.json({
|
|
||||||
limit: '50mb',
|
|
||||||
verify(req: Request, res: Response, buf: any) {
|
|
||||||
req.body = buf;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Access log
|
|
||||||
app.use(function(req: Request, res: Response, next: NextFunction) {
|
|
||||||
if (req.url != '/health') {
|
|
||||||
// count the request for the log prefix
|
|
||||||
log.incRequests()
|
|
||||||
// build access message
|
|
||||||
let body = "";
|
|
||||||
if (req.method == 'POST' && req.body) {
|
|
||||||
body += " body: "
|
|
||||||
try {
|
|
||||||
body += JSON.stringify(req.body)
|
|
||||||
} catch(e) {
|
|
||||||
body += req.body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info(`Incoming request => ${req.method} ${req.url}${body}`);
|
|
||||||
}
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
|
|
||||||
// *********************************************************************************************************************
|
|
||||||
// Routes
|
|
||||||
|
|
||||||
// Show welcome message
|
|
||||||
app.get("/", ( req: Request, res: Response ) => {
|
|
||||||
res.send({
|
|
||||||
"msg": "FlareSolverr is ready!",
|
|
||||||
"version": version,
|
|
||||||
"userAgent": getUserAgent()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Health endpoint. this endpoint is special because it doesn't print traces
|
|
||||||
app.get("/health", ( req: Request, res: Response ) => {
|
|
||||||
res.send({
|
|
||||||
"status": "ok"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Controller v1
|
|
||||||
app.post("/v1", async( req: Request, res: Response ) => {
|
|
||||||
await controllerV1(req, res);
|
|
||||||
});
|
|
||||||
|
|
||||||
// *********************************************************************************************************************
|
|
||||||
|
|
||||||
// Unknown paths or verbs
|
|
||||||
app.use(function (req : Request, res : Response) {
|
|
||||||
res.status(404)
|
|
||||||
.send({"error": "Unknown resource or HTTP verb"})
|
|
||||||
})
|
|
||||||
|
|
||||||
// Errors
|
|
||||||
app.use(function (err: any, req: Request, res: Response, next: NextFunction) {
|
|
||||||
if (err) {
|
|
||||||
let msg = 'Invalid request: ' + err;
|
|
||||||
msg = msg.replace("\n", "").replace("\r", "")
|
|
||||||
log.error(msg)
|
|
||||||
res.send({"error": msg})
|
|
||||||
} else {
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
module.exports = app;
|
|
||||||
0
src/bottle_plugins/__init__.py
Normal file
0
src/bottle_plugins/__init__.py
Normal file
22
src/bottle_plugins/error_plugin.py
Normal file
22
src/bottle_plugins/error_plugin.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from bottle import response
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
def error_plugin(callback):
|
||||||
|
"""
|
||||||
|
Bottle plugin to handle exceptions
|
||||||
|
https://stackoverflow.com/a/32764250
|
||||||
|
"""
|
||||||
|
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
try:
|
||||||
|
actual_response = callback(*args, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(str(e))
|
||||||
|
actual_response = {
|
||||||
|
"error": str(e)
|
||||||
|
}
|
||||||
|
response.status = 500
|
||||||
|
return actual_response
|
||||||
|
|
||||||
|
return wrapper
|
||||||
23
src/bottle_plugins/logger_plugin.py
Normal file
23
src/bottle_plugins/logger_plugin.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from bottle import request, response
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
def logger_plugin(callback):
|
||||||
|
"""
|
||||||
|
Bottle plugin to use logging module
|
||||||
|
http://bottlepy.org/docs/dev/plugindev.html
|
||||||
|
|
||||||
|
Wrap a Bottle request so that a log line is emitted after it's handled.
|
||||||
|
(This decorator can be extended to take the desired logger as a param.)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
actual_response = callback(*args, **kwargs)
|
||||||
|
if not request.url.endswith("/health"):
|
||||||
|
logging.info('%s %s %s %s' % (request.remote_addr,
|
||||||
|
request.method,
|
||||||
|
request.url,
|
||||||
|
response.status))
|
||||||
|
return actual_response
|
||||||
|
|
||||||
|
return wrapper
|
||||||
66
src/bottle_plugins/prometheus_plugin.py
Normal file
66
src/bottle_plugins/prometheus_plugin.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
|
from bottle import request
|
||||||
|
from dtos import V1RequestBase, V1ResponseBase
|
||||||
|
from metrics import start_metrics_http_server, REQUEST_COUNTER, REQUEST_DURATION
|
||||||
|
|
||||||
|
PROMETHEUS_ENABLED = os.environ.get('PROMETHEUS_ENABLED', 'false').lower() == 'true'
|
||||||
|
PROMETHEUS_PORT = int(os.environ.get('PROMETHEUS_PORT', 8192))
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
if PROMETHEUS_ENABLED:
|
||||||
|
start_metrics_http_server(PROMETHEUS_PORT)
|
||||||
|
|
||||||
|
|
||||||
|
def prometheus_plugin(callback):
|
||||||
|
"""
|
||||||
|
Bottle plugin to expose Prometheus metrics
|
||||||
|
http://bottlepy.org/docs/dev/plugindev.html
|
||||||
|
"""
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
actual_response = callback(*args, **kwargs)
|
||||||
|
|
||||||
|
if PROMETHEUS_ENABLED:
|
||||||
|
try:
|
||||||
|
export_metrics(actual_response)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning("Error exporting metrics: " + str(e))
|
||||||
|
|
||||||
|
return actual_response
|
||||||
|
|
||||||
|
def export_metrics(actual_response):
|
||||||
|
res = V1ResponseBase(actual_response)
|
||||||
|
|
||||||
|
if res.startTimestamp is None or res.endTimestamp is None:
|
||||||
|
# skip management and healthcheck endpoints
|
||||||
|
return
|
||||||
|
|
||||||
|
domain = "unknown"
|
||||||
|
if res.solution and res.solution.url:
|
||||||
|
domain = parse_domain_url(res.solution.url)
|
||||||
|
else:
|
||||||
|
# timeout error
|
||||||
|
req = V1RequestBase(request.json)
|
||||||
|
if req.url:
|
||||||
|
domain = parse_domain_url(req.url)
|
||||||
|
|
||||||
|
run_time = (res.endTimestamp - res.startTimestamp) / 1000
|
||||||
|
REQUEST_DURATION.labels(domain=domain).observe(run_time)
|
||||||
|
|
||||||
|
result = "unknown"
|
||||||
|
if res.message == "Challenge solved!":
|
||||||
|
result = "solved"
|
||||||
|
elif res.message == "Challenge not detected!":
|
||||||
|
result = "not_detected"
|
||||||
|
elif res.message.startswith("Error"):
|
||||||
|
result = "error"
|
||||||
|
REQUEST_COUNTER.labels(domain=domain, result=result).inc()
|
||||||
|
|
||||||
|
def parse_domain_url(url):
|
||||||
|
parsed_url = urllib.parse.urlparse(url)
|
||||||
|
return parsed_url.hostname
|
||||||
|
|
||||||
|
return wrapper
|
||||||
110
src/build_package.py
Normal file
110
src/build_package.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
def clean_files():
|
||||||
|
try:
|
||||||
|
shutil.rmtree(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'build'))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
shutil.rmtree(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'dist'))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
shutil.rmtree(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'dist_chrome'))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def download_chromium():
|
||||||
|
# https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/
|
||||||
|
revision = "1260008" if os.name == 'nt' else '1260015'
|
||||||
|
arch = 'Win_x64' if os.name == 'nt' else 'Linux_x64'
|
||||||
|
dl_file = 'chrome-win' if os.name == 'nt' else 'chrome-linux'
|
||||||
|
dl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'dist_chrome')
|
||||||
|
dl_path_folder = os.path.join(dl_path, dl_file)
|
||||||
|
dl_path_zip = dl_path_folder + '.zip'
|
||||||
|
|
||||||
|
# response = requests.get(
|
||||||
|
# f'https://commondatastorage.googleapis.com/chromium-browser-snapshots/{arch}/LAST_CHANGE',
|
||||||
|
# timeout=30)
|
||||||
|
# revision = response.text.strip()
|
||||||
|
print("Downloading revision: " + revision)
|
||||||
|
|
||||||
|
os.mkdir(dl_path)
|
||||||
|
with requests.get(
|
||||||
|
f'https://commondatastorage.googleapis.com/chromium-browser-snapshots/{arch}/{revision}/{dl_file}.zip',
|
||||||
|
stream=True) as r:
|
||||||
|
r.raise_for_status()
|
||||||
|
with open(dl_path_zip, 'wb') as f:
|
||||||
|
for chunk in r.iter_content(chunk_size=8192):
|
||||||
|
f.write(chunk)
|
||||||
|
print("File downloaded: " + dl_path_zip)
|
||||||
|
with zipfile.ZipFile(dl_path_zip, 'r') as zip_ref:
|
||||||
|
zip_ref.extractall(dl_path)
|
||||||
|
os.remove(dl_path_zip)
|
||||||
|
|
||||||
|
chrome_path = os.path.join(dl_path, "chrome")
|
||||||
|
shutil.move(dl_path_folder, chrome_path)
|
||||||
|
print("Extracted in: " + chrome_path)
|
||||||
|
|
||||||
|
if os.name != 'nt':
|
||||||
|
# Give executable permissions for *nix
|
||||||
|
# file * | grep executable | cut -d: -f1
|
||||||
|
print("Giving executable permissions...")
|
||||||
|
execs = ['chrome', 'chrome_crashpad_handler', 'chrome_sandbox', 'chrome-wrapper', 'xdg-mime', 'xdg-settings']
|
||||||
|
for exec_file in execs:
|
||||||
|
exec_path = os.path.join(chrome_path, exec_file)
|
||||||
|
os.chmod(exec_path, 0o755)
|
||||||
|
|
||||||
|
|
||||||
|
def run_pyinstaller():
|
||||||
|
sep = ';' if os.name == 'nt' else ':'
|
||||||
|
result = subprocess.run([sys.executable, "-m", "PyInstaller",
|
||||||
|
"--icon", "resources/flaresolverr_logo.ico",
|
||||||
|
"--add-data", f"package.json{sep}.",
|
||||||
|
"--add-data", f"{os.path.join('dist_chrome', 'chrome')}{sep}chrome",
|
||||||
|
os.path.join("src", "flaresolverr.py")],
|
||||||
|
cwd=os.pardir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
if result.returncode != 0:
|
||||||
|
print(result.stderr.decode('utf-8'))
|
||||||
|
raise Exception("Error running pyInstaller")
|
||||||
|
|
||||||
|
|
||||||
|
def compress_package():
|
||||||
|
dist_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'dist')
|
||||||
|
package_folder = os.path.join(dist_folder, 'package')
|
||||||
|
shutil.move(os.path.join(dist_folder, 'flaresolverr'), os.path.join(package_folder, 'flaresolverr'))
|
||||||
|
print("Package folder: " + package_folder)
|
||||||
|
|
||||||
|
compr_format = 'zip' if os.name == 'nt' else 'gztar'
|
||||||
|
compr_file_name = 'flaresolverr_windows_x64' if os.name == 'nt' else 'flaresolverr_linux_x64'
|
||||||
|
compr_file_path = os.path.join(dist_folder, compr_file_name)
|
||||||
|
shutil.make_archive(compr_file_path, compr_format, package_folder)
|
||||||
|
print("Compressed file path: " + compr_file_path)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print("Building package...")
|
||||||
|
print("Platform: " + platform.platform())
|
||||||
|
|
||||||
|
print("Cleaning previous build...")
|
||||||
|
clean_files()
|
||||||
|
|
||||||
|
print("Downloading Chromium...")
|
||||||
|
download_chromium()
|
||||||
|
|
||||||
|
print("Building pyinstaller executable... ")
|
||||||
|
run_pyinstaller()
|
||||||
|
|
||||||
|
print("Compressing package... ")
|
||||||
|
compress_package()
|
||||||
|
|
||||||
|
# NOTE: python -m pip install pyinstaller
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import log from "../services/log";
|
|
||||||
|
|
||||||
export enum CaptchaType {
|
|
||||||
re = 'reCaptcha',
|
|
||||||
h = 'hCaptcha'
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SolverOptions {
|
|
||||||
url: string
|
|
||||||
sitekey: string
|
|
||||||
type: CaptchaType
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Solver = (options: SolverOptions) => Promise<string>
|
|
||||||
|
|
||||||
const captchaSolvers: { [key: string]: Solver } = {}
|
|
||||||
|
|
||||||
export default (): Solver => {
|
|
||||||
const method = process.env.CAPTCHA_SOLVER
|
|
||||||
|
|
||||||
if (!method || method.toLowerCase() == 'none') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(method in captchaSolvers)) {
|
|
||||||
try {
|
|
||||||
captchaSolvers[method] = require('./' + method).default as Solver
|
|
||||||
} catch (e) {
|
|
||||||
if (e.code === 'MODULE_NOT_FOUND') {
|
|
||||||
throw Error(`The solver '${method}' is not a valid captcha solving method.`)
|
|
||||||
} else {
|
|
||||||
console.error(e)
|
|
||||||
throw Error(`An error occurred loading the solver '${method}'.`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info(`Using '${method}' to solve the captcha.`);
|
|
||||||
|
|
||||||
return captchaSolvers[method]
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
// todo: avoid puppeter objects
|
|
||||||
import {SetCookie, Headers, HttpMethod} from 'puppeteer'
|
|
||||||
import {Request, Response} from 'express';
|
|
||||||
|
|
||||||
import log from '../services/log'
|
|
||||||
import {browserRequest, ChallengeResolutionResultT, ChallengeResolutionT} from "../services/solver";
|
|
||||||
import {SessionCreateOptions} from "../services/sessions";
|
|
||||||
const sessions = require('../services/sessions')
|
|
||||||
const version: string = 'v' + require('../../package.json').version
|
|
||||||
|
|
||||||
interface V1Routes {
|
|
||||||
[key: string]: (params: V1RequestBase, response: V1ResponseBase) => Promise<void>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Proxy {
|
|
||||||
url?: string
|
|
||||||
username?: string
|
|
||||||
password?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1RequestBase {
|
|
||||||
cmd: string
|
|
||||||
cookies?: SetCookie[],
|
|
||||||
maxTimeout?: number
|
|
||||||
proxy?: Proxy
|
|
||||||
session: string
|
|
||||||
headers?: Headers // deprecated v2, not used
|
|
||||||
userAgent?: string // deprecated v2, not used
|
|
||||||
}
|
|
||||||
|
|
||||||
interface V1RequestSession extends V1RequestBase {
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1Request extends V1RequestBase {
|
|
||||||
url: string
|
|
||||||
method?: HttpMethod
|
|
||||||
postData?: string
|
|
||||||
returnOnlyCookies?: boolean
|
|
||||||
download?: boolean // deprecated v2, not used
|
|
||||||
returnRawHtml?: boolean // deprecated v2, not used
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1ResponseBase {
|
|
||||||
status: string
|
|
||||||
message: string
|
|
||||||
startTimestamp: number
|
|
||||||
endTimestamp: number
|
|
||||||
version: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1ResponseSolution extends V1ResponseBase {
|
|
||||||
solution: ChallengeResolutionResultT
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1ResponseSession extends V1ResponseBase {
|
|
||||||
session: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface V1ResponseSessions extends V1ResponseBase {
|
|
||||||
sessions: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const routes: V1Routes = {
|
|
||||||
'sessions.create': async (params: V1RequestSession, response: V1ResponseSession): Promise<void> => {
|
|
||||||
const options: SessionCreateOptions = {
|
|
||||||
oneTimeSession: false,
|
|
||||||
cookies: params.cookies,
|
|
||||||
maxTimeout: params.maxTimeout,
|
|
||||||
proxy: params.proxy
|
|
||||||
}
|
|
||||||
const { sessionId, browser } = await sessions.create(params.session, options)
|
|
||||||
if (browser) {
|
|
||||||
response.status = "ok";
|
|
||||||
response.message = "Session created successfully.";
|
|
||||||
response.session = sessionId
|
|
||||||
} else {
|
|
||||||
throw Error('Error creating session.')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'sessions.list': async (params: V1RequestSession, response: V1ResponseSessions): Promise<void> => {
|
|
||||||
response.status = "ok";
|
|
||||||
response.message = "";
|
|
||||||
response.sessions = sessions.list();
|
|
||||||
},
|
|
||||||
'sessions.destroy': async (params: V1RequestSession, response: V1ResponseBase): Promise<void> => {
|
|
||||||
if (await sessions.destroy(params.session)) {
|
|
||||||
response.status = "ok";
|
|
||||||
response.message = "The session has been removed.";
|
|
||||||
} else {
|
|
||||||
throw Error('This session does not exist.')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'request.get': async (params: V1Request, response: V1ResponseSolution): Promise<void> => {
|
|
||||||
params.method = 'GET'
|
|
||||||
if (params.postData) {
|
|
||||||
throw Error('Cannot use "postBody" when sending a GET request.')
|
|
||||||
}
|
|
||||||
if (params.returnRawHtml) {
|
|
||||||
log.warn("Request parameter 'returnRawHtml' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
if (params.download) {
|
|
||||||
log.warn("Request parameter 'download' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
const result: ChallengeResolutionT = await browserRequest(params)
|
|
||||||
|
|
||||||
response.status = result.status;
|
|
||||||
response.message = result.message;
|
|
||||||
response.solution = result.result;
|
|
||||||
if (response.message) {
|
|
||||||
log.info(response.message)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'request.post': async (params: V1Request, response: V1ResponseSolution): Promise<void> => {
|
|
||||||
params.method = 'POST'
|
|
||||||
if (!params.postData) {
|
|
||||||
throw Error('Must send param "postBody" when sending a POST request.')
|
|
||||||
}
|
|
||||||
if (params.returnRawHtml) {
|
|
||||||
log.warn("Request parameter 'returnRawHtml' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
if (params.download) {
|
|
||||||
log.warn("Request parameter 'download' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
const result: ChallengeResolutionT = await browserRequest(params)
|
|
||||||
|
|
||||||
response.status = result.status;
|
|
||||||
response.message = result.message;
|
|
||||||
response.solution = result.result;
|
|
||||||
if (response.message) {
|
|
||||||
log.info(response.message)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function controllerV1(req: Request, res: Response): Promise<void> {
|
|
||||||
const response: V1ResponseBase = {
|
|
||||||
status: null,
|
|
||||||
message: null,
|
|
||||||
startTimestamp: Date.now(),
|
|
||||||
endTimestamp: 0,
|
|
||||||
version: version
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const params: V1RequestBase = req.body
|
|
||||||
// do some validations
|
|
||||||
if (!params.cmd) {
|
|
||||||
throw Error("Request parameter 'cmd' is mandatory.")
|
|
||||||
}
|
|
||||||
if (params.headers) {
|
|
||||||
log.warn("Request parameter 'headers' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
if (params.userAgent) {
|
|
||||||
log.warn("Request parameter 'userAgent' was removed in FlareSolverr v2.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// set default values
|
|
||||||
if (!params.maxTimeout || params.maxTimeout < 1) {
|
|
||||||
params.maxTimeout = 60000;
|
|
||||||
}
|
|
||||||
|
|
||||||
// execute the command
|
|
||||||
const route = routes[params.cmd]
|
|
||||||
if (route) {
|
|
||||||
await route(params, response)
|
|
||||||
} else {
|
|
||||||
throw Error(`The command '${params.cmd}' is invalid.`)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
res.status(500)
|
|
||||||
response.status = "error";
|
|
||||||
response.message = e.toString();
|
|
||||||
log.error(response.message)
|
|
||||||
}
|
|
||||||
|
|
||||||
response.endTimestamp = Date.now()
|
|
||||||
log.info(`Response in ${(response.endTimestamp - response.startTimestamp) / 1000} s`)
|
|
||||||
res.send(response)
|
|
||||||
}
|
|
||||||
86
src/dtos.py
Normal file
86
src/dtos.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
STATUS_OK = "ok"
|
||||||
|
STATUS_ERROR = "error"
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeResolutionResultT:
|
||||||
|
url: str = None
|
||||||
|
status: int = None
|
||||||
|
headers: list = None
|
||||||
|
response: str = None
|
||||||
|
cookies: list = None
|
||||||
|
userAgent: str = None
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
|
|
||||||
|
|
||||||
|
class ChallengeResolutionT:
|
||||||
|
status: str = None
|
||||||
|
message: str = None
|
||||||
|
result: ChallengeResolutionResultT = None
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
|
if self.result is not None:
|
||||||
|
self.result = ChallengeResolutionResultT(self.result)
|
||||||
|
|
||||||
|
|
||||||
|
class V1RequestBase(object):
|
||||||
|
# V1RequestBase
|
||||||
|
cmd: str = None
|
||||||
|
cookies: list = None
|
||||||
|
maxTimeout: int = None
|
||||||
|
proxy: dict = None
|
||||||
|
session: str = None
|
||||||
|
session_ttl_minutes: int = None
|
||||||
|
headers: list = None # deprecated v2.0.0, not used
|
||||||
|
userAgent: str = None # deprecated v2.0.0, not used
|
||||||
|
|
||||||
|
# V1Request
|
||||||
|
url: str = None
|
||||||
|
postData: str = None
|
||||||
|
returnOnlyCookies: bool = None
|
||||||
|
download: bool = None # deprecated v2.0.0, not used
|
||||||
|
returnRawHtml: bool = None # deprecated v2.0.0, not used
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
|
|
||||||
|
|
||||||
|
class V1ResponseBase(object):
|
||||||
|
# V1ResponseBase
|
||||||
|
status: str = None
|
||||||
|
message: str = None
|
||||||
|
session: str = None
|
||||||
|
sessions: list[str] = None
|
||||||
|
startTimestamp: int = None
|
||||||
|
endTimestamp: int = None
|
||||||
|
version: str = None
|
||||||
|
|
||||||
|
# V1ResponseSolution
|
||||||
|
solution: ChallengeResolutionResultT = None
|
||||||
|
|
||||||
|
# hidden vars
|
||||||
|
__error_500__: bool = False
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
|
if self.solution is not None:
|
||||||
|
self.solution = ChallengeResolutionResultT(self.solution)
|
||||||
|
|
||||||
|
|
||||||
|
class IndexResponse(object):
|
||||||
|
msg: str = None
|
||||||
|
version: str = None
|
||||||
|
userAgent: str = None
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
|
|
||||||
|
|
||||||
|
class HealthResponse(object):
|
||||||
|
status: str = None
|
||||||
|
|
||||||
|
def __init__(self, _dict):
|
||||||
|
self.__dict__.update(_dict)
|
||||||
125
src/flaresolverr.py
Normal file
125
src/flaresolverr.py
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import certifi
|
||||||
|
from bottle import run, response, Bottle, request, ServerAdapter
|
||||||
|
|
||||||
|
from bottle_plugins.error_plugin import error_plugin
|
||||||
|
from bottle_plugins.logger_plugin import logger_plugin
|
||||||
|
from bottle_plugins import prometheus_plugin
|
||||||
|
from dtos import V1RequestBase
|
||||||
|
import flaresolverr_service
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
|
class JSONErrorBottle(Bottle):
|
||||||
|
"""
|
||||||
|
Handle 404 errors
|
||||||
|
"""
|
||||||
|
def default_error_handler(self, res):
|
||||||
|
response.content_type = 'application/json'
|
||||||
|
return json.dumps(dict(error=res.body, status_code=res.status_code))
|
||||||
|
|
||||||
|
|
||||||
|
app = JSONErrorBottle()
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
"""
|
||||||
|
Show welcome message
|
||||||
|
"""
|
||||||
|
res = flaresolverr_service.index_endpoint()
|
||||||
|
return utils.object_to_dict(res)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/health')
|
||||||
|
def health():
|
||||||
|
"""
|
||||||
|
Healthcheck endpoint.
|
||||||
|
This endpoint is special because it doesn't print traces
|
||||||
|
"""
|
||||||
|
res = flaresolverr_service.health_endpoint()
|
||||||
|
return utils.object_to_dict(res)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post('/v1')
|
||||||
|
def controller_v1():
|
||||||
|
"""
|
||||||
|
Controller v1
|
||||||
|
"""
|
||||||
|
req = V1RequestBase(request.json)
|
||||||
|
res = flaresolverr_service.controller_v1_endpoint(req)
|
||||||
|
if res.__error_500__:
|
||||||
|
response.status = 500
|
||||||
|
return utils.object_to_dict(res)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# check python version
|
||||||
|
if sys.version_info < (3, 9):
|
||||||
|
raise Exception("The Python version is less than 3.9, a version equal to or higher is required.")
|
||||||
|
|
||||||
|
# fix for HEADLESS=false in Windows binary
|
||||||
|
# https://stackoverflow.com/a/27694505
|
||||||
|
if os.name == 'nt':
|
||||||
|
import multiprocessing
|
||||||
|
multiprocessing.freeze_support()
|
||||||
|
|
||||||
|
# fix ssl certificates for compiled binaries
|
||||||
|
# https://github.com/pyinstaller/pyinstaller/issues/7229
|
||||||
|
# https://stackoverflow.com/questions/55736855/how-to-change-the-cafile-argument-in-the-ssl-module-in-python3
|
||||||
|
os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
|
||||||
|
os.environ["SSL_CERT_FILE"] = certifi.where()
|
||||||
|
|
||||||
|
# validate configuration
|
||||||
|
log_level = os.environ.get('LOG_LEVEL', 'info').upper()
|
||||||
|
log_html = utils.get_config_log_html()
|
||||||
|
headless = utils.get_config_headless()
|
||||||
|
server_host = os.environ.get('HOST', '0.0.0.0')
|
||||||
|
server_port = int(os.environ.get('PORT', 8191))
|
||||||
|
|
||||||
|
# configure logger
|
||||||
|
logger_format = '%(asctime)s %(levelname)-8s %(message)s'
|
||||||
|
if log_level == 'DEBUG':
|
||||||
|
logger_format = '%(asctime)s %(levelname)-8s ReqId %(thread)s %(message)s'
|
||||||
|
logging.basicConfig(
|
||||||
|
format=logger_format,
|
||||||
|
level=log_level,
|
||||||
|
datefmt='%Y-%m-%d %H:%M:%S',
|
||||||
|
handlers=[
|
||||||
|
logging.StreamHandler(sys.stdout)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
# disable warning traces from urllib3
|
||||||
|
logging.getLogger('urllib3').setLevel(logging.ERROR)
|
||||||
|
logging.getLogger('selenium.webdriver.remote.remote_connection').setLevel(logging.WARNING)
|
||||||
|
logging.getLogger('undetected_chromedriver').setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
logging.info(f'FlareSolverr {utils.get_flaresolverr_version()}')
|
||||||
|
logging.debug('Debug log enabled')
|
||||||
|
|
||||||
|
# Get current OS for global variable
|
||||||
|
utils.get_current_platform()
|
||||||
|
|
||||||
|
# test browser installation
|
||||||
|
flaresolverr_service.test_browser_installation()
|
||||||
|
|
||||||
|
# start bootle plugins
|
||||||
|
# plugin order is important
|
||||||
|
app.install(logger_plugin)
|
||||||
|
app.install(error_plugin)
|
||||||
|
prometheus_plugin.setup()
|
||||||
|
app.install(prometheus_plugin.prometheus_plugin)
|
||||||
|
|
||||||
|
# start webserver
|
||||||
|
# default server 'wsgiref' does not support concurrent requests
|
||||||
|
# https://github.com/FlareSolverr/FlareSolverr/issues/680
|
||||||
|
# https://github.com/Pylons/waitress/issues/31
|
||||||
|
class WaitressServerPoll(ServerAdapter):
|
||||||
|
def run(self, handler):
|
||||||
|
from waitress import serve
|
||||||
|
serve(handler, host=self.host, port=self.port, asyncore_use_poll=True)
|
||||||
|
run(app, host=server_host, port=server_port, quiet=True, server=WaitressServerPoll)
|
||||||
403
src/flaresolverr_service.py
Normal file
403
src/flaresolverr_service.py
Normal file
@@ -0,0 +1,403 @@
|
|||||||
|
import logging
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from datetime import timedelta
|
||||||
|
from html import escape
|
||||||
|
from urllib.parse import unquote, quote
|
||||||
|
|
||||||
|
from func_timeout import FunctionTimedOut, func_timeout
|
||||||
|
from DrissionPage import ChromiumPage
|
||||||
|
from DrissionPage._units.listener import DataPacket
|
||||||
|
|
||||||
|
import utils
|
||||||
|
from dtos import (STATUS_ERROR, STATUS_OK, ChallengeResolutionResultT,
|
||||||
|
ChallengeResolutionT, HealthResponse, IndexResponse,
|
||||||
|
V1RequestBase, V1ResponseBase)
|
||||||
|
from sessions import SessionsStorage
|
||||||
|
|
||||||
|
ACCESS_DENIED_TITLES = [
|
||||||
|
# Cloudflare
|
||||||
|
'Access denied',
|
||||||
|
# Cloudflare http://bitturk.net/ Firefox
|
||||||
|
'Attention Required! | Cloudflare'
|
||||||
|
]
|
||||||
|
ACCESS_DENIED_SELECTORS = [
|
||||||
|
# Cloudflare
|
||||||
|
'div.cf-error-title span.cf-code-label span',
|
||||||
|
# Cloudflare http://bitturk.net/ Firefox
|
||||||
|
'#cf-error-details div.cf-error-overview h1'
|
||||||
|
]
|
||||||
|
CHALLENGE_TITLES = [
|
||||||
|
# Cloudflare
|
||||||
|
'Just a moment...',
|
||||||
|
# DDoS-GUARD
|
||||||
|
'DDoS-Guard'
|
||||||
|
]
|
||||||
|
CHALLENGE_SELECTORS = [
|
||||||
|
# Cloudflare
|
||||||
|
'#cf-challenge-running', '.ray_id', '.attack-box', '#cf-please-wait', '#challenge-spinner', '#trk_jschal_js', '#turnstile-wrapper', '.lds-ring',
|
||||||
|
# Custom CloudFlare for EbookParadijs, Film-Paleis, MuziekFabriek and Puur-Hollands
|
||||||
|
'td.info #js_info',
|
||||||
|
# Fairlane / pararius.com
|
||||||
|
'div.vc div.text-box h2'
|
||||||
|
]
|
||||||
|
SHORT_TIMEOUT = 1
|
||||||
|
SESSIONS_STORAGE = SessionsStorage()
|
||||||
|
|
||||||
|
|
||||||
|
def test_browser_installation():
|
||||||
|
logging.info("Testing web browser installation...")
|
||||||
|
logging.info("Platform: " + platform.platform())
|
||||||
|
|
||||||
|
chrome_exe_path = utils.get_chrome_exe_path()
|
||||||
|
if chrome_exe_path is None:
|
||||||
|
logging.error("Chrome / Chromium web browser not installed!")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
logging.info("Chrome / Chromium path: " + chrome_exe_path)
|
||||||
|
|
||||||
|
chrome_major_version = utils.get_chrome_major_version()
|
||||||
|
if chrome_major_version == '':
|
||||||
|
logging.error("Chrome / Chromium version not detected!")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
logging.info("Chrome / Chromium major version: " + chrome_major_version)
|
||||||
|
|
||||||
|
logging.info("Launching web browser...")
|
||||||
|
user_agent = utils.get_user_agent()
|
||||||
|
logging.info("FlareSolverr User-Agent: " + user_agent)
|
||||||
|
logging.info("Test successful!")
|
||||||
|
|
||||||
|
|
||||||
|
def index_endpoint() -> IndexResponse:
|
||||||
|
res = IndexResponse({})
|
||||||
|
res.msg = "FlareSolverr is ready!"
|
||||||
|
res.version = utils.get_flaresolverr_version()
|
||||||
|
res.userAgent = utils.get_user_agent()
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def health_endpoint() -> HealthResponse:
|
||||||
|
res = HealthResponse({})
|
||||||
|
res.status = STATUS_OK
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def controller_v1_endpoint(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
start_ts = int(time.time() * 1000)
|
||||||
|
logging.info(f"Incoming request => POST /v1 body: {utils.object_to_dict(req)}")
|
||||||
|
res: V1ResponseBase
|
||||||
|
try:
|
||||||
|
res = _controller_v1_handler(req)
|
||||||
|
except Exception as e:
|
||||||
|
res = V1ResponseBase({})
|
||||||
|
res.__error_500__ = True
|
||||||
|
res.status = STATUS_ERROR
|
||||||
|
res.message = "Error: " + str(e)
|
||||||
|
logging.error(res.message)
|
||||||
|
|
||||||
|
res.startTimestamp = start_ts
|
||||||
|
res.endTimestamp = int(time.time() * 1000)
|
||||||
|
res.version = utils.get_flaresolverr_version()
|
||||||
|
logging.debug(f"Response => POST /v1 body: {utils.object_to_dict(res)}")
|
||||||
|
logging.info(f"Response in {(res.endTimestamp - res.startTimestamp) / 1000} s")
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def _controller_v1_handler(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
# do some validations
|
||||||
|
if req.cmd is None:
|
||||||
|
raise Exception("Request parameter 'cmd' is mandatory.")
|
||||||
|
if req.headers is not None:
|
||||||
|
logging.warning("Request parameter 'headers' was removed in FlareSolverr v2.")
|
||||||
|
if req.userAgent is not None:
|
||||||
|
logging.warning("Request parameter 'userAgent' was removed in FlareSolverr v2.")
|
||||||
|
|
||||||
|
# set default values
|
||||||
|
if req.maxTimeout is None or int(req.maxTimeout) < 1:
|
||||||
|
req.maxTimeout = 60000
|
||||||
|
|
||||||
|
# execute the command
|
||||||
|
res: V1ResponseBase
|
||||||
|
if req.cmd == 'sessions.create':
|
||||||
|
res = _cmd_sessions_create(req)
|
||||||
|
elif req.cmd == 'sessions.list':
|
||||||
|
res = _cmd_sessions_list(req)
|
||||||
|
elif req.cmd == 'sessions.destroy':
|
||||||
|
res = _cmd_sessions_destroy(req)
|
||||||
|
elif req.cmd == 'request.get':
|
||||||
|
res = _cmd_request_get(req)
|
||||||
|
elif req.cmd == 'request.post':
|
||||||
|
res = _cmd_request_post(req)
|
||||||
|
else:
|
||||||
|
raise Exception(f"Request parameter 'cmd' = '{req.cmd}' is invalid.")
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def _cmd_request_get(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
# do some validations
|
||||||
|
if req.url is None:
|
||||||
|
raise Exception("Request parameter 'url' is mandatory in 'request.get' command.")
|
||||||
|
if req.postData is not None:
|
||||||
|
raise Exception("Cannot use 'postBody' when sending a GET request.")
|
||||||
|
if req.returnRawHtml is not None:
|
||||||
|
logging.warning("Request parameter 'returnRawHtml' was removed in FlareSolverr v2.")
|
||||||
|
if req.download is not None:
|
||||||
|
logging.warning("Request parameter 'download' was removed in FlareSolverr v2.")
|
||||||
|
|
||||||
|
challenge_res = _resolve_challenge(req, 'GET')
|
||||||
|
res = V1ResponseBase({})
|
||||||
|
res.status = challenge_res.status
|
||||||
|
res.message = challenge_res.message
|
||||||
|
res.solution = challenge_res.result
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def _cmd_request_post(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
# do some validations
|
||||||
|
if req.postData is None:
|
||||||
|
raise Exception("Request parameter 'postData' is mandatory in 'request.post' command.")
|
||||||
|
if req.returnRawHtml is not None:
|
||||||
|
logging.warning("Request parameter 'returnRawHtml' was removed in FlareSolverr v2.")
|
||||||
|
if req.download is not None:
|
||||||
|
logging.warning("Request parameter 'download' was removed in FlareSolverr v2.")
|
||||||
|
|
||||||
|
challenge_res = _resolve_challenge(req, 'POST')
|
||||||
|
res = V1ResponseBase({})
|
||||||
|
res.status = challenge_res.status
|
||||||
|
res.message = challenge_res.message
|
||||||
|
res.solution = challenge_res.result
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def _cmd_sessions_create(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
logging.debug("Creating new session...")
|
||||||
|
|
||||||
|
session, fresh = SESSIONS_STORAGE.create(session_id=req.session, proxy=req.proxy)
|
||||||
|
session_id = session.session_id
|
||||||
|
|
||||||
|
if not fresh:
|
||||||
|
return V1ResponseBase({
|
||||||
|
"status": STATUS_OK,
|
||||||
|
"message": "Session already exists.",
|
||||||
|
"session": session_id
|
||||||
|
})
|
||||||
|
|
||||||
|
return V1ResponseBase({
|
||||||
|
"status": STATUS_OK,
|
||||||
|
"message": "Session created successfully.",
|
||||||
|
"session": session_id
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def _cmd_sessions_list(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
session_ids = SESSIONS_STORAGE.session_ids()
|
||||||
|
|
||||||
|
return V1ResponseBase({
|
||||||
|
"status": STATUS_OK,
|
||||||
|
"message": "",
|
||||||
|
"sessions": session_ids
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def _cmd_sessions_destroy(req: V1RequestBase) -> V1ResponseBase:
|
||||||
|
session_id = req.session
|
||||||
|
existed = SESSIONS_STORAGE.destroy(session_id)
|
||||||
|
|
||||||
|
if not existed:
|
||||||
|
raise Exception("The session doesn't exist.")
|
||||||
|
|
||||||
|
return V1ResponseBase({
|
||||||
|
"status": STATUS_OK,
|
||||||
|
"message": "The session has been removed."
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_challenge(req: V1RequestBase, method: str) -> ChallengeResolutionT:
|
||||||
|
timeout = int(req.maxTimeout) / 1000
|
||||||
|
driver = None
|
||||||
|
try:
|
||||||
|
if req.session:
|
||||||
|
session_id = req.session
|
||||||
|
ttl = timedelta(minutes=req.session_ttl_minutes) if req.session_ttl_minutes else None
|
||||||
|
session, fresh = SESSIONS_STORAGE.get(session_id, ttl)
|
||||||
|
|
||||||
|
if fresh:
|
||||||
|
logging.debug(f"new session created to perform the request (session_id={session_id})")
|
||||||
|
else:
|
||||||
|
logging.debug(f"existing session is used to perform the request (session_id={session_id}, "
|
||||||
|
f"lifetime={str(session.lifetime())}, ttl={str(ttl)})")
|
||||||
|
|
||||||
|
driver = session.driver
|
||||||
|
else:
|
||||||
|
driver = utils.get_webdriver(req.proxy)
|
||||||
|
logging.debug('New instance of webdriver has been created to perform the request')
|
||||||
|
return func_timeout(timeout, _evil_logic, (req, driver, method))
|
||||||
|
except FunctionTimedOut:
|
||||||
|
raise Exception(f'Error solving the challenge. Timeout after {timeout} seconds.')
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception('Error solving the challenge. ' + str(e).replace('\n', '\\n'))
|
||||||
|
finally:
|
||||||
|
if not req.session and driver is not None:
|
||||||
|
if utils.PLATFORM_VERSION == "nt":
|
||||||
|
driver.close()
|
||||||
|
driver.quit()
|
||||||
|
logging.debug('A used instance of webdriver has been destroyed')
|
||||||
|
|
||||||
|
def click_verify(driver: ChromiumPage) -> DataPacket:
|
||||||
|
try:
|
||||||
|
bde = (
|
||||||
|
driver
|
||||||
|
.ele("@Style=border: 0px; margin: 0px; padding: 0px;", timeout=10)
|
||||||
|
.shadow_root
|
||||||
|
.ele("tag:iframe", timeout=10)
|
||||||
|
.ele('tag:body', timeout=10)
|
||||||
|
.shadow_root
|
||||||
|
)
|
||||||
|
ve = bde.ele("text:Verify you are human", timeout=10)
|
||||||
|
|
||||||
|
driver.listen.resume()
|
||||||
|
ve.click()
|
||||||
|
data = driver.listen.wait(count=1,timeout=5)
|
||||||
|
|
||||||
|
if isinstance(data, DataPacket):
|
||||||
|
return data
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.debug("Cloudflare verify checkbox not found on the page. %s", repr(e))
|
||||||
|
|
||||||
|
|
||||||
|
def search_challenge(driver: ChromiumPage) -> bool:
|
||||||
|
page_title = driver.title.lower()
|
||||||
|
|
||||||
|
# find challenge by title
|
||||||
|
for title in CHALLENGE_TITLES:
|
||||||
|
if title.lower() == page_title:
|
||||||
|
logging.debug("Challenge detected. Title found: %s", page_title)
|
||||||
|
return True
|
||||||
|
# find challenge by selectors
|
||||||
|
if driver.wait.eles_loaded(locators=CHALLENGE_SELECTORS, timeout=SHORT_TIMEOUT, any_one=True):
|
||||||
|
logging.debug("Challenge detected. One of selectors found")
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _evil_logic(req: V1RequestBase, driver: ChromiumPage, method: str) -> ChallengeResolutionT:
|
||||||
|
res = ChallengeResolutionT({})
|
||||||
|
res.status = STATUS_OK
|
||||||
|
res.message = ""
|
||||||
|
|
||||||
|
|
||||||
|
# navigate to the page
|
||||||
|
logging.debug('Navigating to... %s', req.url)
|
||||||
|
driver.listen.start(req.url)
|
||||||
|
if method == 'POST':
|
||||||
|
_post_request(req, driver)
|
||||||
|
else:
|
||||||
|
driver.get(req.url)
|
||||||
|
data = driver.listen.wait(count=1,timeout=5)
|
||||||
|
driver.listen.pause()
|
||||||
|
|
||||||
|
# set cookies if required
|
||||||
|
if req.cookies is not None and len(req.cookies) > 0:
|
||||||
|
logging.debug('Setting cookies...')
|
||||||
|
for cookie in req.cookies:
|
||||||
|
driver.set.cookies.remove(cookie['name'])
|
||||||
|
driver.set.cookies(cookie)
|
||||||
|
# reload the page
|
||||||
|
driver.listen.resume()
|
||||||
|
if method == 'POST':
|
||||||
|
_post_request(req, driver)
|
||||||
|
else:
|
||||||
|
driver.get(req.url)
|
||||||
|
data = driver.listen.wait(count=1, timeout=5)
|
||||||
|
driver.listen.pause()
|
||||||
|
|
||||||
|
# wait for the page
|
||||||
|
if utils.get_config_log_html():
|
||||||
|
logging.debug("Response HTML:\n%s", driver.page_source)
|
||||||
|
|
||||||
|
page_title = driver.title
|
||||||
|
# find access denied titles
|
||||||
|
for title in ACCESS_DENIED_TITLES:
|
||||||
|
if title == page_title:
|
||||||
|
raise Exception('Cloudflare has blocked this request. '
|
||||||
|
'Probably your IP is banned for this site, check in your web browser.')
|
||||||
|
# find access denied selectors
|
||||||
|
if driver.wait.eles_loaded(locators=ACCESS_DENIED_SELECTORS, timeout=SHORT_TIMEOUT, any_one=True):
|
||||||
|
raise Exception('Cloudflare has blocked this request. '
|
||||||
|
'Probably your IP is banned for this site, check in your web browser.')
|
||||||
|
|
||||||
|
attempt = 0
|
||||||
|
challenge_found = True
|
||||||
|
while challenge_found:
|
||||||
|
try:
|
||||||
|
attempt += 1
|
||||||
|
|
||||||
|
if search_challenge(driver):
|
||||||
|
if attempt == 1:
|
||||||
|
logging.info("Challenge detected.")
|
||||||
|
|
||||||
|
data = click_verify(driver)
|
||||||
|
else:
|
||||||
|
if attempt == 1:
|
||||||
|
logging.info("Challenge not detected!")
|
||||||
|
res.message = "Challenge not detected!"
|
||||||
|
else:
|
||||||
|
logging.info("Challenge solved!")
|
||||||
|
res.message = "Challenge solved!"
|
||||||
|
break
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.debug("Cloudflare check exception")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
challenge_res = ChallengeResolutionResultT({})
|
||||||
|
challenge_res.url = driver.url
|
||||||
|
if data is not None and data.response is not None:
|
||||||
|
challenge_res.status = data.response.status
|
||||||
|
if not req.returnOnlyCookies:
|
||||||
|
challenge_res.response = data.response.body
|
||||||
|
challenge_res.headers = data.response.headers.copy()
|
||||||
|
|
||||||
|
challenge_res.cookies = driver.cookies()
|
||||||
|
challenge_res.userAgent = utils.get_user_agent(driver)
|
||||||
|
|
||||||
|
res.result = challenge_res
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def _post_request(req: V1RequestBase, driver: ChromiumPage):
|
||||||
|
post_form = f'<form id="hackForm" action="{req.url}" method="POST">'
|
||||||
|
query_string = req.postData if req.postData[0] != '?' else req.postData[1:]
|
||||||
|
pairs = query_string.split('&')
|
||||||
|
for pair in pairs:
|
||||||
|
parts = pair.split('=')
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
name = unquote(parts[0])
|
||||||
|
except Exception:
|
||||||
|
name = parts[0]
|
||||||
|
if name == 'submit':
|
||||||
|
continue
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
value = unquote(parts[1])
|
||||||
|
except Exception:
|
||||||
|
value = parts[1]
|
||||||
|
post_form += f'<input type="text" name="{escape(quote(name))}" value="{escape(quote(value))}"><br>'
|
||||||
|
post_form += '</form>'
|
||||||
|
html_content = f"""
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
{post_form}
|
||||||
|
<script>document.getElementById('hackForm').submit();</script>
|
||||||
|
</body>
|
||||||
|
</html>"""
|
||||||
|
driver.get("data:text/html;charset=utf-8,{html_content}".format(html_content=html_content))
|
||||||
32
src/metrics.py
Normal file
32
src/metrics.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from prometheus_client import Counter, Histogram, start_http_server
|
||||||
|
import time
|
||||||
|
|
||||||
|
REQUEST_COUNTER = Counter(
|
||||||
|
name='flaresolverr_request',
|
||||||
|
documentation='Total requests with result',
|
||||||
|
labelnames=['domain', 'result']
|
||||||
|
)
|
||||||
|
REQUEST_DURATION = Histogram(
|
||||||
|
name='flaresolverr_request_duration',
|
||||||
|
documentation='Request duration in seconds',
|
||||||
|
labelnames=['domain'],
|
||||||
|
buckets=[0, 10, 25, 50]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def serve(port):
|
||||||
|
start_http_server(port=port)
|
||||||
|
while True:
|
||||||
|
time.sleep(600)
|
||||||
|
|
||||||
|
|
||||||
|
def start_metrics_http_server(prometheus_port: int):
|
||||||
|
logging.info(f"Serving Prometheus exporter on http://0.0.0.0:{prometheus_port}/metrics")
|
||||||
|
from threading import Thread
|
||||||
|
Thread(
|
||||||
|
target=serve,
|
||||||
|
kwargs=dict(port=prometheus_port),
|
||||||
|
daemon=True,
|
||||||
|
).start()
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
import {Page, Response} from 'puppeteer'
|
|
||||||
|
|
||||||
import log from "../services/log";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class contains the logic to solve protections provided by CloudFlare
|
|
||||||
**/
|
|
||||||
|
|
||||||
const BAN_SELECTORS = ['span[data-translate="error"]'];
|
|
||||||
const CHALLENGE_SELECTORS = ['#trk_jschal_js', '.ray_id', '.attack-box', '#cf-please-wait'];
|
|
||||||
const CAPTCHA_SELECTORS = ['input[name="cf_captcha_kind"]'];
|
|
||||||
|
|
||||||
export default async function resolveChallenge(url: string, page: Page, response: Response): Promise<Response> {
|
|
||||||
|
|
||||||
// look for challenge and return fast if not detected
|
|
||||||
if (response.headers().server &&
|
|
||||||
response.headers().server.startsWith('cloudflare') &&
|
|
||||||
(response.status() == 403 || response.status() == 503)) {
|
|
||||||
log.info('Cloudflare detected');
|
|
||||||
} else {
|
|
||||||
log.info('Cloudflare not detected');
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await findAnySelector(page, BAN_SELECTORS)) {
|
|
||||||
throw new Error('Cloudflare has blocked this request. Probably your IP is banned for this site, check in your web browser.')
|
|
||||||
}
|
|
||||||
|
|
||||||
let selectorFound = false;
|
|
||||||
if (response.status() > 400) {
|
|
||||||
|
|
||||||
// find Cloudflare selectors
|
|
||||||
let selector: string = await findAnySelector(page, CHALLENGE_SELECTORS)
|
|
||||||
if (selector) {
|
|
||||||
selectorFound = true;
|
|
||||||
log.debug(`Javascript challenge element '${selector}' detected.`)
|
|
||||||
log.debug('Waiting for Cloudflare challenge...')
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
selector = await findAnySelector(page, CHALLENGE_SELECTORS)
|
|
||||||
if (!selector) {
|
|
||||||
// solved!
|
|
||||||
log.debug('Challenge element not found')
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
log.debug(`Javascript challenge element '${selector}' detected.`)
|
|
||||||
|
|
||||||
// new Cloudflare Challenge #cf-please-wait
|
|
||||||
const displayStyle = await page.evaluate((selector) => {
|
|
||||||
return getComputedStyle(document.querySelector(selector)).getPropertyValue("display");
|
|
||||||
}, selector);
|
|
||||||
if (displayStyle == "none") {
|
|
||||||
// spinner is hidden, could be a captcha or not
|
|
||||||
log.debug('Challenge element is hidden')
|
|
||||||
// wait until redirecting disappears
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
await page.waitFor(1000)
|
|
||||||
const displayStyle2 = await page.evaluate(() => {
|
|
||||||
return getComputedStyle(document.querySelector('#cf-spinner-redirecting')).getPropertyValue("display");
|
|
||||||
});
|
|
||||||
if (displayStyle2 == "none") {
|
|
||||||
break // hCaptcha detected
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
break // redirection completed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
log.debug('Challenge element is visible')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.debug('Found challenge element again')
|
|
||||||
|
|
||||||
} catch (error)
|
|
||||||
{
|
|
||||||
log.debug("Unexpected error: " + error);
|
|
||||||
if (!error.toString().includes("Execution context was destroyed")) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug('Waiting for Cloudflare challenge...')
|
|
||||||
await page.waitFor(1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug('Validating HTML code...')
|
|
||||||
} else {
|
|
||||||
log.debug(`No challenge element detected.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// some sites use cloudflare but there is no challenge
|
|
||||||
log.debug(`Javascript challenge not detected. Status code: ${response.status()}`);
|
|
||||||
selectorFound = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for CAPTCHA challenge
|
|
||||||
if (await findAnySelector(page, CAPTCHA_SELECTORS)) {
|
|
||||||
log.info('CAPTCHA challenge detected');
|
|
||||||
throw new Error('FlareSolverr can not resolve CAPTCHA challenges. Since the captcha doesn\'t always appear, you may have better luck with the next request.');
|
|
||||||
|
|
||||||
// const captchaSolver = getCaptchaSolver()
|
|
||||||
// if (captchaSolver) {
|
|
||||||
// // to-do: get the params
|
|
||||||
// log.info('Waiting to receive captcha token to bypass challenge...')
|
|
||||||
// const token = await captchaSolver({
|
|
||||||
// url,
|
|
||||||
// sitekey,
|
|
||||||
// type: captchaType
|
|
||||||
// })
|
|
||||||
// log.debug(`Token received: ${token}`);
|
|
||||||
// // to-do: send the token
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// throw new Error('Captcha detected but no automatic solver is configured.');
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
if (!selectorFound)
|
|
||||||
{
|
|
||||||
throw new Error('No challenge selectors found, unable to proceed.')
|
|
||||||
} else {
|
|
||||||
log.info('Challenge solved');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function findAnySelector(page: Page, selectors: string[]) {
|
|
||||||
for (const selector of selectors) {
|
|
||||||
const cfChallengeElem = await page.$(selector)
|
|
||||||
if (cfChallengeElem) {
|
|
||||||
return selector;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import log from './services/log'
|
|
||||||
import {testWebBrowserInstallation} from "./services/sessions";
|
|
||||||
|
|
||||||
const app = require("./app");
|
|
||||||
const version: string = 'v' + require('../package.json').version
|
|
||||||
const serverPort: number = Number(process.env.PORT) || 8191
|
|
||||||
const serverHost: string = process.env.HOST || '0.0.0.0'
|
|
||||||
|
|
||||||
function validateEnvironmentVariables() {
|
|
||||||
// ip and port variables are validated by nodejs
|
|
||||||
if (process.env.LOG_LEVEL && ['error', 'warn', 'info', 'verbose', 'debug'].indexOf(process.env.LOG_LEVEL) == -1) {
|
|
||||||
log.error(`The environment variable 'LOG_LEVEL' is wrong. Check the documentation.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (process.env.LOG_HTML && ['true', 'false'].indexOf(process.env.LOG_HTML) == -1) {
|
|
||||||
log.error(`The environment variable 'LOG_HTML' is wrong. Check the documentation.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (process.env.HEADLESS && ['true', 'false'].indexOf(process.env.HEADLESS) == -1) {
|
|
||||||
log.error(`The environment variable 'HEADLESS' is wrong. Check the documentation.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
// todo: fix resolvers
|
|
||||||
// try {
|
|
||||||
// getCaptchaSolver();
|
|
||||||
// } catch (e) {
|
|
||||||
// log.error(`The environment variable 'CAPTCHA_SOLVER' is wrong. ${e.message}`);
|
|
||||||
// process.exit(1);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init
|
|
||||||
log.info(`FlareSolverr ${version}`);
|
|
||||||
log.debug('Debug log enabled');
|
|
||||||
|
|
||||||
process.on('SIGTERM', () => {
|
|
||||||
// Capture signal on Docker Stop #158
|
|
||||||
log.info("Process interrupted")
|
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
|
|
||||||
validateEnvironmentVariables();
|
|
||||||
|
|
||||||
testWebBrowserInstallation().then(() => {
|
|
||||||
// Start server
|
|
||||||
app.listen(serverPort, serverHost, () => {
|
|
||||||
log.info(`Listening on http://${serverHost}:${serverPort}`);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
let requests = 0
|
|
||||||
|
|
||||||
const LOG_HTML: boolean = process.env.LOG_HTML == 'true';
|
|
||||||
|
|
||||||
function toIsoString(date: Date) {
|
|
||||||
// this function fixes Date.toISOString() adding timezone
|
|
||||||
let tzo = -date.getTimezoneOffset(),
|
|
||||||
dif = tzo >= 0 ? '+' : '-',
|
|
||||||
pad = function(num: number) {
|
|
||||||
let norm = Math.floor(Math.abs(num));
|
|
||||||
return (norm < 10 ? '0' : '') + norm;
|
|
||||||
};
|
|
||||||
|
|
||||||
return date.getFullYear() +
|
|
||||||
'-' + pad(date.getMonth() + 1) +
|
|
||||||
'-' + pad(date.getDate()) +
|
|
||||||
'T' + pad(date.getHours()) +
|
|
||||||
':' + pad(date.getMinutes()) +
|
|
||||||
':' + pad(date.getSeconds()) +
|
|
||||||
dif + pad(tzo / 60) +
|
|
||||||
':' + pad(tzo % 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
incRequests: () => {
|
|
||||||
requests++
|
|
||||||
},
|
|
||||||
html(html: string) {
|
|
||||||
if (LOG_HTML) {
|
|
||||||
this.debug(html)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
...require('console-log-level')(
|
|
||||||
{level: process.env.LOG_LEVEL || 'info',
|
|
||||||
prefix(level: string) {
|
|
||||||
const req = (requests > 0) ? ` REQ-${requests}` : '';
|
|
||||||
return `${toIsoString(new Date())} ${level.toUpperCase()}${req}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
import {v1 as UUIDv1} from 'uuid'
|
|
||||||
import * as path from 'path'
|
|
||||||
import {SetCookie, Browser} from 'puppeteer'
|
|
||||||
|
|
||||||
import log from './log'
|
|
||||||
import {Proxy} from "../controllers/v1";
|
|
||||||
|
|
||||||
const puppeteer = require('puppeteer');
|
|
||||||
|
|
||||||
export interface SessionsCacheItem {
|
|
||||||
sessionId: string
|
|
||||||
browser: Browser
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SessionsCache {
|
|
||||||
[key: string]: SessionsCacheItem
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SessionCreateOptions {
|
|
||||||
oneTimeSession: boolean
|
|
||||||
cookies?: SetCookie[],
|
|
||||||
maxTimeout?: number
|
|
||||||
proxy?: Proxy
|
|
||||||
}
|
|
||||||
|
|
||||||
const sessionCache: SessionsCache = {}
|
|
||||||
let webBrowserUserAgent: string;
|
|
||||||
|
|
||||||
function buildExtraPrefsFirefox(proxy: Proxy): object {
|
|
||||||
// Default configurations are defined here
|
|
||||||
// https://github.com/puppeteer/puppeteer/blob/v3.3.0/src/Launcher.ts#L481
|
|
||||||
const extraPrefsFirefox = {
|
|
||||||
// Disable newtabpage
|
|
||||||
"browser.newtabpage.enabled": false,
|
|
||||||
"browser.startup.homepage": "about:blank",
|
|
||||||
|
|
||||||
// Do not warn when closing all open tabs
|
|
||||||
"browser.tabs.warnOnClose": false,
|
|
||||||
|
|
||||||
// Disable telemetry
|
|
||||||
"toolkit.telemetry.reportingpolicy.firstRun": false,
|
|
||||||
|
|
||||||
// Disable first-run welcome page
|
|
||||||
"startup.homepage_welcome_url": "about:blank",
|
|
||||||
"startup.homepage_welcome_url.additional": "",
|
|
||||||
|
|
||||||
// Disable images to speed up load
|
|
||||||
"permissions.default.image": 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// proxy.url format => http://<host>:<port>
|
|
||||||
if (proxy && proxy.url) {
|
|
||||||
const [host, portStr] = proxy.url.replace(/https?:\/\//g, '').split(':');
|
|
||||||
const port = parseInt(portStr);
|
|
||||||
|
|
||||||
const proxyPrefs = {
|
|
||||||
// Proxy configuration
|
|
||||||
"network.proxy.ftp": host,
|
|
||||||
"network.proxy.ftp_port": port,
|
|
||||||
"network.proxy.http": host,
|
|
||||||
"network.proxy.http_port": port,
|
|
||||||
"network.proxy.share_proxy_settings": true,
|
|
||||||
"network.proxy.socks": host,
|
|
||||||
"network.proxy.socks_port": port,
|
|
||||||
"network.proxy.ssl": host,
|
|
||||||
"network.proxy.ssl_port": port,
|
|
||||||
"network.proxy.type": 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge objects
|
|
||||||
Object.assign(extraPrefsFirefox, proxyPrefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return extraPrefsFirefox;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUserAgent() {
|
|
||||||
return webBrowserUserAgent
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function testWebBrowserInstallation(): Promise<void> {
|
|
||||||
log.info("Testing web browser installation...")
|
|
||||||
const session = await create(null, {
|
|
||||||
oneTimeSession: true
|
|
||||||
})
|
|
||||||
const page = await session.browser.newPage()
|
|
||||||
await page.goto("https://www.google.com")
|
|
||||||
webBrowserUserAgent = await page.evaluate(() => navigator.userAgent)
|
|
||||||
|
|
||||||
// replace Linux ARM user-agent because it's detected
|
|
||||||
if (webBrowserUserAgent.toLocaleLowerCase().includes('linux arm')) {
|
|
||||||
webBrowserUserAgent = webBrowserUserAgent.replace(/linux arm[^;]+;/i, 'Linux x86_64;')
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("FlareSolverr User-Agent: " + webBrowserUserAgent)
|
|
||||||
await page.close()
|
|
||||||
await destroy(session.sessionId)
|
|
||||||
|
|
||||||
log.info("Test successful")
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function create(session: string, options: SessionCreateOptions): Promise<SessionsCacheItem> {
|
|
||||||
const sessionId = session || UUIDv1()
|
|
||||||
|
|
||||||
// NOTE: cookies can't be set in the session, you need to open the page first
|
|
||||||
|
|
||||||
const puppeteerOptions: any = {
|
|
||||||
product: 'firefox',
|
|
||||||
headless: process.env.HEADLESS !== 'false',
|
|
||||||
}
|
|
||||||
|
|
||||||
puppeteerOptions.extraPrefsFirefox = buildExtraPrefsFirefox(options.proxy)
|
|
||||||
|
|
||||||
// if we are running inside executable binary, change browser path
|
|
||||||
if (typeof (process as any).pkg !== 'undefined') {
|
|
||||||
const exe = process.platform === "win32" ? 'firefox.exe' : 'firefox';
|
|
||||||
puppeteerOptions.executablePath = path.join(path.dirname(process.execPath), 'firefox', exe)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug('Launching web browser...')
|
|
||||||
let browser: Browser = await puppeteer.launch(puppeteerOptions)
|
|
||||||
if (!browser) {
|
|
||||||
throw Error(`Failed to launch web browser.`)
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionCache[sessionId] = {
|
|
||||||
sessionId: sessionId,
|
|
||||||
browser: browser
|
|
||||||
}
|
|
||||||
|
|
||||||
return sessionCache[sessionId]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function list(): string[] {
|
|
||||||
return Object.keys(sessionCache)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function destroy(id: string): Promise<boolean>{
|
|
||||||
if (id && sessionCache.hasOwnProperty(id)) {
|
|
||||||
const { browser } = sessionCache[id]
|
|
||||||
if (browser) {
|
|
||||||
await browser.close()
|
|
||||||
delete sessionCache[id]
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
export function get(id: string): SessionsCacheItem {
|
|
||||||
return sessionCache[id]
|
|
||||||
}
|
|
||||||
@@ -1,216 +0,0 @@
|
|||||||
import {Response, Headers, Page} from 'puppeteer'
|
|
||||||
const Timeout = require('await-timeout');
|
|
||||||
|
|
||||||
import log from './log'
|
|
||||||
import {SessionCreateOptions, SessionsCacheItem} from "./sessions";
|
|
||||||
import {V1Request} from "../controllers/v1";
|
|
||||||
import cloudflareProvider from '../providers/cloudflare';
|
|
||||||
|
|
||||||
const sessions = require('./sessions')
|
|
||||||
|
|
||||||
export interface ChallengeResolutionResultT {
|
|
||||||
url: string
|
|
||||||
status: number,
|
|
||||||
headers?: Headers,
|
|
||||||
response: string,
|
|
||||||
cookies: object[]
|
|
||||||
userAgent: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ChallengeResolutionT {
|
|
||||||
status?: string
|
|
||||||
message: string
|
|
||||||
result: ChallengeResolutionResultT
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveChallengeWithTimeout(params: V1Request, session: SessionsCacheItem) {
|
|
||||||
const timer = new Timeout();
|
|
||||||
try {
|
|
||||||
const promise = resolveChallenge(params, session);
|
|
||||||
return await Promise.race([
|
|
||||||
promise,
|
|
||||||
timer.set(params.maxTimeout, `Maximum timeout reached. maxTimeout=${params.maxTimeout} (ms)`)
|
|
||||||
]);
|
|
||||||
} finally {
|
|
||||||
timer.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveChallenge(params: V1Request, session: SessionsCacheItem): Promise<ChallengeResolutionT | void> {
|
|
||||||
try {
|
|
||||||
let status = 'ok'
|
|
||||||
let message = ''
|
|
||||||
|
|
||||||
const page: Page = await session.browser.newPage()
|
|
||||||
|
|
||||||
// the Puppeter timeout should be half the maxTimeout because we reload the page and wait for challenge
|
|
||||||
// the user can set a really high maxTimeout if he wants to
|
|
||||||
await page.setDefaultNavigationTimeout(params.maxTimeout / 2)
|
|
||||||
|
|
||||||
// the user-agent is changed just for linux arm build
|
|
||||||
await page.setUserAgent(sessions.getUserAgent())
|
|
||||||
|
|
||||||
// set the proxy
|
|
||||||
if (params.proxy) {
|
|
||||||
log.debug(`Using proxy: ${params.proxy.url}`);
|
|
||||||
// todo: credentials are not working
|
|
||||||
// if (params.proxy.username) {
|
|
||||||
// await page.authenticate({
|
|
||||||
// username: params.proxy.username,
|
|
||||||
// password: params.proxy.password
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// go to the page
|
|
||||||
log.debug(`Navigating to... ${params.url}`)
|
|
||||||
let response: Response = await gotoPage(params, page);
|
|
||||||
|
|
||||||
// set cookies
|
|
||||||
if (params.cookies) {
|
|
||||||
for (const cookie of params.cookies) {
|
|
||||||
// the other fields in the cookie can cause issues
|
|
||||||
await page.setCookie({
|
|
||||||
"name": cookie.name,
|
|
||||||
"value": cookie.value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// reload the page
|
|
||||||
response = await gotoPage(params, page);
|
|
||||||
}
|
|
||||||
|
|
||||||
// log html in debug mode
|
|
||||||
log.html(await page.content())
|
|
||||||
|
|
||||||
// detect protection services and solve challenges
|
|
||||||
try {
|
|
||||||
response = await cloudflareProvider(params.url, page, response);
|
|
||||||
|
|
||||||
// is response is ok
|
|
||||||
// reload the page to be sure we get the real page
|
|
||||||
log.debug("Reloading the page")
|
|
||||||
response = await gotoPage(params, page);
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
status = "error";
|
|
||||||
message = "Cloudflare " + e.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const payload: ChallengeResolutionT = {
|
|
||||||
status,
|
|
||||||
message,
|
|
||||||
result: {
|
|
||||||
url: page.url(),
|
|
||||||
status: response.status(),
|
|
||||||
headers: response.headers(),
|
|
||||||
response: null,
|
|
||||||
cookies: await page.cookies(),
|
|
||||||
userAgent: sessions.getUserAgent()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.returnOnlyCookies) {
|
|
||||||
payload.result.headers = null;
|
|
||||||
payload.result.userAgent = null;
|
|
||||||
} else {
|
|
||||||
payload.result.response = await page.content()
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure the page is closed because if it isn't and error will be thrown
|
|
||||||
// when a user uses a temporary session, the browser make be quit before
|
|
||||||
// the page is properly closed.
|
|
||||||
await page.close()
|
|
||||||
|
|
||||||
return payload
|
|
||||||
} catch (e) {
|
|
||||||
log.error("Unexpected error: " + e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function gotoPage(params: V1Request, page: Page): Promise<Response> {
|
|
||||||
let response: Response;
|
|
||||||
if (params.method != 'POST') {
|
|
||||||
response = await page.goto(params.url, {waitUntil: 'domcontentloaded'});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// post hack
|
|
||||||
// first request a page without cloudflare
|
|
||||||
response = await page.goto(params.url, {waitUntil: 'domcontentloaded'});
|
|
||||||
await page.setContent(
|
|
||||||
`
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
function parseQuery(queryString) {
|
|
||||||
var query = {};
|
|
||||||
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
|
|
||||||
for (var i = 0; i < pairs.length; i++) {
|
|
||||||
var pair = pairs[i].split('=');
|
|
||||||
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || '');
|
|
||||||
}
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
const form = document.createElement('form');
|
|
||||||
form.method = 'POST';
|
|
||||||
form.action = '${params.url}';
|
|
||||||
|
|
||||||
const params = parseQuery('${params.postData}');
|
|
||||||
for (const key in params) {
|
|
||||||
if (params.hasOwnProperty(key)) {
|
|
||||||
const hiddenField = document.createElement('input');
|
|
||||||
hiddenField.type = 'hidden';
|
|
||||||
hiddenField.name = key;
|
|
||||||
hiddenField.value = params[key];
|
|
||||||
form.appendChild(hiddenField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.appendChild(form);
|
|
||||||
form.submit();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
`
|
|
||||||
);
|
|
||||||
await page.waitFor(2000)
|
|
||||||
try {
|
|
||||||
await page.waitForNavigation({waitUntil: 'domcontentloaded', timeout: 2000})
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
}
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function browserRequest(params: V1Request): Promise<ChallengeResolutionT> {
|
|
||||||
const oneTimeSession = params.session === undefined;
|
|
||||||
|
|
||||||
const options: SessionCreateOptions = {
|
|
||||||
oneTimeSession: oneTimeSession,
|
|
||||||
cookies: params.cookies,
|
|
||||||
maxTimeout: params.maxTimeout,
|
|
||||||
proxy: params.proxy
|
|
||||||
}
|
|
||||||
|
|
||||||
const session: SessionsCacheItem = oneTimeSession
|
|
||||||
? await sessions.create(null, options)
|
|
||||||
: sessions.get(params.session)
|
|
||||||
|
|
||||||
if (!session) {
|
|
||||||
throw Error('This session does not exist. Use \'list_sessions\' to see all the existing sessions.')
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return await resolveChallengeWithTimeout(params, session)
|
|
||||||
} catch (error) {
|
|
||||||
throw Error("Unable to process browser request. " + error)
|
|
||||||
} finally {
|
|
||||||
if (oneTimeSession) {
|
|
||||||
await sessions.destroy(session.sessionId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
84
src/sessions.py
Normal file
84
src/sessions.py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import logging
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from typing import Optional, Tuple
|
||||||
|
from uuid import uuid1
|
||||||
|
|
||||||
|
from DrissionPage import ChromiumPage
|
||||||
|
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Session:
|
||||||
|
session_id: str
|
||||||
|
driver: ChromiumPage
|
||||||
|
created_at: datetime
|
||||||
|
|
||||||
|
def lifetime(self) -> timedelta:
|
||||||
|
return datetime.now() - self.created_at
|
||||||
|
|
||||||
|
|
||||||
|
class SessionsStorage:
|
||||||
|
"""SessionsStorage creates, stores and process all the sessions"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.sessions = {}
|
||||||
|
|
||||||
|
def create(self, session_id: Optional[str] = None, proxy: Optional[dict] = None,
|
||||||
|
force_new: Optional[bool] = False) -> Tuple[Session, bool]:
|
||||||
|
"""create creates new instance of ChromiumPage if necessary,
|
||||||
|
assign defined (or newly generated) session_id to the instance
|
||||||
|
and returns the session object. If a new session has been created
|
||||||
|
second argument is set to True.
|
||||||
|
|
||||||
|
Note: The function is idempotent, so in case if session_id
|
||||||
|
already exists in the storage a new instance of ChromiumPage won't be created
|
||||||
|
and existing session will be returned. Second argument defines if
|
||||||
|
new session has been created (True) or an existing one was used (False).
|
||||||
|
"""
|
||||||
|
session_id = session_id or str(uuid1())
|
||||||
|
|
||||||
|
if force_new:
|
||||||
|
self.destroy(session_id)
|
||||||
|
|
||||||
|
if self.exists(session_id):
|
||||||
|
return self.sessions[session_id], False
|
||||||
|
|
||||||
|
driver = utils.get_webdriver(proxy)
|
||||||
|
created_at = datetime.now()
|
||||||
|
session = Session(session_id, driver, created_at)
|
||||||
|
|
||||||
|
self.sessions[session_id] = session
|
||||||
|
|
||||||
|
return session, True
|
||||||
|
|
||||||
|
def exists(self, session_id: str) -> bool:
|
||||||
|
return session_id in self.sessions
|
||||||
|
|
||||||
|
def destroy(self, session_id: str) -> bool:
|
||||||
|
"""destroy closes the driver instance and removes session from the storage.
|
||||||
|
The function is noop if session_id doesn't exist.
|
||||||
|
The function returns True if session was found and destroyed,
|
||||||
|
and False if session_id wasn't found.
|
||||||
|
"""
|
||||||
|
if not self.exists(session_id):
|
||||||
|
return False
|
||||||
|
|
||||||
|
session = self.sessions.pop(session_id)
|
||||||
|
if utils.PLATFORM_VERSION == "nt":
|
||||||
|
session.driver.close()
|
||||||
|
session.driver.quit()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get(self, session_id: str, ttl: Optional[timedelta] = None) -> Tuple[Session, bool]:
|
||||||
|
session, fresh = self.create(session_id)
|
||||||
|
|
||||||
|
if ttl is not None and not fresh and session.lifetime() > ttl:
|
||||||
|
logging.debug(f'session\'s lifetime has expired, so the session is recreated (session_id={session_id})')
|
||||||
|
session, fresh = self.create(session_id, force_new=True)
|
||||||
|
|
||||||
|
return session, fresh
|
||||||
|
|
||||||
|
def session_ids(self) -> list[str]:
|
||||||
|
return list(self.sessions.keys())
|
||||||
632
src/tests.py
Normal file
632
src/tests.py
Normal file
@@ -0,0 +1,632 @@
|
|||||||
|
import unittest
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from webtest import TestApp
|
||||||
|
|
||||||
|
from dtos import IndexResponse, HealthResponse, V1ResponseBase, STATUS_OK, STATUS_ERROR
|
||||||
|
import flaresolverr
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
|
def _find_obj_by_key(key: str, value: str, _list: list) -> Optional[dict]:
|
||||||
|
for obj in _list:
|
||||||
|
if obj[key] == value:
|
||||||
|
return obj
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class TestFlareSolverr(unittest.TestCase):
|
||||||
|
|
||||||
|
proxy_url = "http://127.0.0.1:8888"
|
||||||
|
proxy_socks_url = "socks5://127.0.0.1:1080"
|
||||||
|
google_url = "https://www.google.com"
|
||||||
|
post_url = "https://httpbin.org/post"
|
||||||
|
cloudflare_url = "https://nowsecure.nl"
|
||||||
|
cloudflare_url_2 = "https://idope.se/torrent-list/harry/"
|
||||||
|
ddos_guard_url = "https://anidex.info/"
|
||||||
|
fairlane_url = "https://www.pararius.com/apartments/amsterdam"
|
||||||
|
custom_cloudflare_url = "https://www.muziekfabriek.org"
|
||||||
|
cloudflare_blocked_url = "https://cpasbiens3.fr/index.php?do=search&subaction=search"
|
||||||
|
|
||||||
|
app = TestApp(flaresolverr.app)
|
||||||
|
# wait until the server is ready
|
||||||
|
app.get('/')
|
||||||
|
|
||||||
|
def test_wrong_endpoint(self):
|
||||||
|
res = self.app.get('/wrong', status=404)
|
||||||
|
self.assertEqual(res.status_code, 404)
|
||||||
|
|
||||||
|
body = res.json
|
||||||
|
self.assertEqual("Not found: '/wrong'", body['error'])
|
||||||
|
self.assertEqual(404, body['status_code'])
|
||||||
|
|
||||||
|
def test_index_endpoint(self):
|
||||||
|
res = self.app.get('/')
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = IndexResponse(res.json)
|
||||||
|
self.assertEqual("FlareSolverr is ready!", body.msg)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
self.assertIn("Chrome/", body.userAgent)
|
||||||
|
|
||||||
|
def test_health_endpoint(self):
|
||||||
|
res = self.app.get('/health')
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = HealthResponse(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
|
||||||
|
def test_v1_endpoint_wrong_cmd(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.bad",
|
||||||
|
"url": self.google_url
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertEqual("Error: Request parameter 'cmd' = 'request.bad' is invalid.", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_no_cloudflare(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Google</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_cloudflare_js_1(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.cloudflare_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.cloudflare_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>nowSecure</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "cf_clearance", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Cloudflare cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 30)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_cloudflare_js_2(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.cloudflare_url_2
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.cloudflare_url_2, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>harry - idope torrent search</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "cf_clearance", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Cloudflare cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 30)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_ddos_guard_js(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.ddos_guard_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.ddos_guard_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>AniDex</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "__ddg1_", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "DDOS-Guard cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 10)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_fairlane_js(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.fairlane_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.fairlane_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Rental Apartments Amsterdam</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "fl_pass_v2_b", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Fairlane cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 50)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_custom_cloudflare_js(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.custom_cloudflare_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.custom_cloudflare_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>MuziekFabriek : Aanmelden</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "ct_anti_ddos_key", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Custom Cloudflare cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 10)
|
||||||
|
|
||||||
|
# todo: test Cmd 'request.get' should return fail with Cloudflare CAPTCHA
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_cloudflare_blocked(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.cloudflare_blocked_url
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertEqual("Error: Error solving the challenge. Cloudflare has blocked this request. "
|
||||||
|
"Probably your IP is banned for this site, check in your web browser.", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_cookies_param(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"cookies": [
|
||||||
|
{
|
||||||
|
"name": "testcookie1",
|
||||||
|
"value": "testvalue1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "testcookie2",
|
||||||
|
"value": "testvalue2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Google</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 1)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
user_cookie1 = _find_obj_by_key("name", "testcookie1", solution.cookies)
|
||||||
|
self.assertIsNotNone(user_cookie1, "User cookie 1 not found")
|
||||||
|
self.assertEqual("testvalue1", user_cookie1["value"])
|
||||||
|
|
||||||
|
user_cookie2 = _find_obj_by_key("name", "testcookie2", solution.cookies)
|
||||||
|
self.assertIsNotNone(user_cookie2, "User cookie 2 not found")
|
||||||
|
self.assertEqual("testvalue2", user_cookie2["value"])
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_returnOnlyCookies_param(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"returnOnlyCookies": True
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIsNone(solution.headers)
|
||||||
|
self.assertIsNone(solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_proxy_http_param(self):
|
||||||
|
"""
|
||||||
|
To configure TinyProxy in local:
|
||||||
|
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
||||||
|
* edit => LogFile "/tmp/tinyproxy.log"
|
||||||
|
* edit => Syslog Off
|
||||||
|
* sudo tinyproxy -d
|
||||||
|
* sudo tail -f /tmp/tinyproxy.log
|
||||||
|
"""
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"proxy": {
|
||||||
|
"url": self.proxy_url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Google</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_proxy_http_param_with_credentials(self):
|
||||||
|
"""
|
||||||
|
To configure TinyProxy in local:
|
||||||
|
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
||||||
|
* edit => LogFile "/tmp/tinyproxy.log"
|
||||||
|
* edit => Syslog Off
|
||||||
|
* add => BasicAuth testuser testpass
|
||||||
|
* sudo tinyproxy -d
|
||||||
|
* sudo tail -f /tmp/tinyproxy.log
|
||||||
|
"""
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"proxy": {
|
||||||
|
"url": self.proxy_url,
|
||||||
|
"username": "testuser",
|
||||||
|
"password": "testpass"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Google</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_proxy_socks_param(self):
|
||||||
|
"""
|
||||||
|
To configure Dante in local:
|
||||||
|
* https://linuxhint.com/set-up-a-socks5-proxy-on-ubuntu-with-dante/
|
||||||
|
* sudo vim /etc/sockd.conf
|
||||||
|
* sudo systemctl restart sockd.service
|
||||||
|
* curl --socks5 socks5://127.0.0.1:1080 https://www.google.com
|
||||||
|
"""
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"proxy": {
|
||||||
|
"url": self.proxy_socks_url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.google_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>Google</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_proxy_wrong_param(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"proxy": {
|
||||||
|
"url": "http://127.0.0.1:43210"
|
||||||
|
}
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertIn("Error: Error solving the challenge. Message: unknown error: net::ERR_PROXY_CONNECTION_FAILED",
|
||||||
|
body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_fail_timeout(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"maxTimeout": 10
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertEqual("Error: Error solving the challenge. Timeout after 0.01 seconds.", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_fail_bad_domain(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": "https://www.google.combad"
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertIn("Message: unknown error: net::ERR_NAME_NOT_RESOLVED", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_deprecated_param(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": self.google_url,
|
||||||
|
"userAgent": "Test User-Agent" # was removed in v2, not used
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_post_no_cloudflare(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.post",
|
||||||
|
"url": self.post_url,
|
||||||
|
"postData": "param1=value1¶m2=value2"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.post_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn('"form": {\n "param1": "value1", \n "param2": "value2"\n }', solution.response)
|
||||||
|
self.assertEqual(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_post_cloudflare(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.post",
|
||||||
|
"url": self.cloudflare_url,
|
||||||
|
"postData": "param1=value1¶m2=value2"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(self.cloudflare_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn("<title>405 Not Allowed</title>", solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "cf_clearance", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Cloudflare cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 30)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_post_fail_no_post_data(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.post",
|
||||||
|
"url": self.google_url
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertIn("Request parameter 'postData' is mandatory in 'request.post' command", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_post_deprecated_param(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.post",
|
||||||
|
"url": self.google_url,
|
||||||
|
"postData": "param1=value1¶m2=value2",
|
||||||
|
"userAgent": "Test User-Agent" # was removed in v2, not used
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge not detected!", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_create_without_session(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Session created successfully.", body.message)
|
||||||
|
self.assertIsNotNone(body.session)
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_create_with_session(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create",
|
||||||
|
"session": "test_create_session"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Session created successfully.", body.message)
|
||||||
|
self.assertEqual(body.session, "test_create_session")
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_create_with_proxy(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create",
|
||||||
|
"proxy": {
|
||||||
|
"url": self.proxy_url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Session created successfully.", body.message)
|
||||||
|
self.assertIsNotNone(body.session)
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_list(self):
|
||||||
|
self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create",
|
||||||
|
"session": "test_list_sessions"
|
||||||
|
})
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.list"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("", body.message)
|
||||||
|
self.assertGreaterEqual(len(body.sessions), 1)
|
||||||
|
self.assertIn("test_list_sessions", body.sessions)
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_destroy_existing_session(self):
|
||||||
|
self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create",
|
||||||
|
"session": "test_destroy_sessions"
|
||||||
|
})
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.destroy",
|
||||||
|
"session": "test_destroy_sessions"
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("The session has been removed.", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_sessions_destroy_non_existing_session(self):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.destroy",
|
||||||
|
"session": "non_existing_session_name"
|
||||||
|
}, status=500)
|
||||||
|
self.assertEqual(res.status_code, 500)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_ERROR, body.status)
|
||||||
|
self.assertEqual("Error: The session doesn't exist.", body.message)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_with_session(self):
|
||||||
|
self.app.post_json('/v1', {
|
||||||
|
"cmd": "sessions.create",
|
||||||
|
"session": "test_request_sessions"
|
||||||
|
})
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"session": "test_request_sessions",
|
||||||
|
"url": self.google_url
|
||||||
|
})
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -1,538 +0,0 @@
|
|||||||
// noinspection DuplicatedCode
|
|
||||||
|
|
||||||
import {Response} from "superagent";
|
|
||||||
import {V1ResponseBase, V1ResponseSession, V1ResponseSessions, V1ResponseSolution} from "../controllers/v1"
|
|
||||||
|
|
||||||
const request = require("supertest");
|
|
||||||
const app = require("../app");
|
|
||||||
const sessions = require('../services/sessions');
|
|
||||||
const version: string = 'v' + require('../../package.json').version
|
|
||||||
|
|
||||||
const proxyUrl = "http://127.0.0.1:8888"
|
|
||||||
const googleUrl = "https://www.google.com";
|
|
||||||
const postUrl = "https://ptsv2.com/t/qv4j3-1634496523";
|
|
||||||
const cfUrl = "https://pirateiro.com/torrents/?search=harry";
|
|
||||||
const cfCaptchaUrl = "https://idope.se"
|
|
||||||
const cfBlockedUrl = "https://www.torrentmafya.org/table.php"
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
// Init session
|
|
||||||
await sessions.testWebBrowserInstallation();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
// Clean sessions
|
|
||||||
const sessionList = sessions.list();
|
|
||||||
for (const session of sessionList) {
|
|
||||||
await sessions.destroy(session);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Test '/' path", () => {
|
|
||||||
test("GET method should return OK ", async () => {
|
|
||||||
const response: Response = await request(app).get("/");
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body.msg).toBe("FlareSolverr is ready!");
|
|
||||||
expect(response.body.version).toBe(version);
|
|
||||||
expect(response.body.userAgent).toContain("Firefox/")
|
|
||||||
});
|
|
||||||
|
|
||||||
test("POST method should fail", async () => {
|
|
||||||
const response: Response = await request(app).post("/");
|
|
||||||
expect(response.statusCode).toBe(404);
|
|
||||||
expect(response.body.error).toBe("Unknown resource or HTTP verb");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Test '/health' path", () => {
|
|
||||||
test("GET method should return OK", async () => {
|
|
||||||
const response: Response = await request(app).get("/health");
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
expect(response.body.status).toBe("ok");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Test '/wrong' path", () => {
|
|
||||||
test("GET method should fail", async () => {
|
|
||||||
const response: Response = await request(app).get("/wrong");
|
|
||||||
expect(response.statusCode).toBe(404);
|
|
||||||
expect(response.body.error).toBe("Unknown resource or HTTP verb");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Test '/v1' path", () => {
|
|
||||||
test("Cmd 'request.bad' should fail", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.bad",
|
|
||||||
"url": googleUrl
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: The command 'request.bad' is invalid.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThanOrEqual(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with no Cloudflare", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
expect(Object.keys(solution.headers).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.response).toContain("<!DOCTYPE html>")
|
|
||||||
expect(Object.keys(solution.cookies).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.userAgent).toContain("Firefox/")
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with Cloudflare JS", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": cfUrl
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(cfUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
expect(Object.keys(solution.headers).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.response).toContain("<!DOCTYPE html>")
|
|
||||||
expect(Object.keys(solution.cookies).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.userAgent).toContain("Firefox/")
|
|
||||||
|
|
||||||
const cfCookie: string = (solution.cookies as any[]).filter(function(cookie) {
|
|
||||||
return cookie.name == "cf_clearance";
|
|
||||||
})[0].value
|
|
||||||
expect(cfCookie.length).toBeGreaterThan(30)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return fail with Cloudflare CAPTCHA", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": cfCaptchaUrl
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Cloudflare Error: FlareSolverr can not resolve CAPTCHA challenges. Since the captcha doesn't always appear, you may have better luck with the next request.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
// solution is filled but not useful
|
|
||||||
expect(apiResponse.solution.url).toContain(cfCaptchaUrl)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.post' should return fail with Cloudflare Blocked", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.post",
|
|
||||||
"url": cfBlockedUrl,
|
|
||||||
"postData": "test1=test2"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Cloudflare Error: Cloudflare has blocked this request. Probably your IP is banned for this site, check in your web browser.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
// solution is filled but not useful
|
|
||||||
expect(apiResponse.solution.url).toContain(cfBlockedUrl)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with 'cookies' param", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"cookies": [
|
|
||||||
{
|
|
||||||
"name": "testcookie1",
|
|
||||||
"value": "testvalue1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "testcookie2",
|
|
||||||
"value": "testvalue2"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(Object.keys(solution.cookies).length).toBeGreaterThan(1)
|
|
||||||
const cookie1: string = (solution.cookies as any[]).filter(function(cookie) {
|
|
||||||
return cookie.name == "testcookie1";
|
|
||||||
})[0].value
|
|
||||||
expect(cookie1).toBe("testvalue1")
|
|
||||||
const cookie2: string = (solution.cookies as any[]).filter(function(cookie) {
|
|
||||||
return cookie.name == "testcookie2";
|
|
||||||
})[0].value
|
|
||||||
expect(cookie2).toBe("testvalue2")
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with 'returnOnlyCookies' param", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"returnOnlyCookies": true
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
expect(solution.headers).toBe(null)
|
|
||||||
expect(solution.response).toBe(null)
|
|
||||||
expect(Object.keys(solution.cookies).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.userAgent).toBe(null)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with 'proxy' param", async () => {
|
|
||||||
/*
|
|
||||||
To configure TinyProxy in local:
|
|
||||||
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
|
||||||
* edit => LogFile "/tmp/tinyproxy.log"
|
|
||||||
* edit => Syslog Off
|
|
||||||
* sudo tinyproxy -d
|
|
||||||
* sudo tail -f /tmp/tinyproxy.log
|
|
||||||
*/
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"proxy": {
|
|
||||||
"url": proxyUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
// todo: credentials are not working
|
|
||||||
test.skip("Cmd 'request.get' should return OK with 'proxy' param with credentials", async () => {
|
|
||||||
/*
|
|
||||||
To configure TinyProxy in local:
|
|
||||||
* sudo vim /etc/tinyproxy/tinyproxy.conf
|
|
||||||
* edit => LogFile "/tmp/tinyproxy.log"
|
|
||||||
* edit => Syslog Off
|
|
||||||
* add => BasicAuth testuser testpass
|
|
||||||
* sudo tinyproxy -d
|
|
||||||
* sudo tail -f /tmp/tinyproxy.log
|
|
||||||
*/
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"proxy": {
|
|
||||||
"url": proxyUrl,
|
|
||||||
"username": "testuser",
|
|
||||||
"password": "testpass"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(solution.status).toContain(200)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should fail with wrong 'proxy' param", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"proxy": {
|
|
||||||
"url": "http://127.0.0.1:43210"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: Unable to process browser request. Error: NS_ERROR_PROXY_CONNECTION_REFUSED at https://www.google.com");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return fail with timeout", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"maxTimeout": 10
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: Unable to process browser request. Error: Maximum timeout reached. maxTimeout=10 (ms)");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should return fail with bad domain", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": "https://www.google.combad"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: Unable to process browser request. Error: NS_ERROR_UNKNOWN_HOST at https://www.google.combad");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should accept deprecated params", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": googleUrl,
|
|
||||||
"userAgent": "Test User-Agent" // was removed in v2, not used
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(googleUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
expect(solution.userAgent).toContain("Firefox/")
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.post' should return OK with no Cloudflare", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.post",
|
|
||||||
"url": postUrl + '/post',
|
|
||||||
"postData": "param1=value1¶m2=value2"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
|
|
||||||
const solution = apiResponse.solution;
|
|
||||||
expect(solution.url).toContain(postUrl)
|
|
||||||
expect(solution.status).toBe(200);
|
|
||||||
expect(Object.keys(solution.headers).length).toBeGreaterThan(0)
|
|
||||||
expect(solution.response).toContain(" I hope you have a lovely day!")
|
|
||||||
expect(Object.keys(solution.cookies).length).toBe(0)
|
|
||||||
expect(solution.userAgent).toContain("Firefox/")
|
|
||||||
|
|
||||||
// check that we sent the date
|
|
||||||
const payload2 = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": postUrl
|
|
||||||
}
|
|
||||||
const response2: Response = await request(app).post("/v1").send(payload2);
|
|
||||||
expect(response2.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse2: V1ResponseSolution = response2.body;
|
|
||||||
expect(apiResponse2.status).toBe("ok");
|
|
||||||
|
|
||||||
const solution2 = apiResponse2.solution;
|
|
||||||
expect(solution2.status).toBe(200);
|
|
||||||
expect(solution2.response).toContain(new Date().toISOString().split(':')[0].replace('T', ' '))
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.post' should fail without 'postData' param", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.post",
|
|
||||||
"url": googleUrl
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: Must send param \"postBody\" when sending a POST request.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThanOrEqual(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'sessions.create' should return OK", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "sessions.create"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSession = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("Session created successfully.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
expect(apiResponse.session.length).toBe(36);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'sessions.create' should return OK with session", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "sessions.create",
|
|
||||||
"session": "2bc6bb20-2f56-11ec-9543-test"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSession = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("Session created successfully.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
expect(apiResponse.session).toBe("2bc6bb20-2f56-11ec-9543-test");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'sessions.list' should return OK", async () => {
|
|
||||||
// create one session for testing
|
|
||||||
const payload0 = {
|
|
||||||
"cmd": "sessions.create"
|
|
||||||
}
|
|
||||||
const response0: Response = await request(app).post("/v1").send(payload0);
|
|
||||||
expect(response0.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
"cmd": "sessions.list"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSessions = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThanOrEqual(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
expect(apiResponse.sessions.length).toBeGreaterThan(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'sessions.destroy' should return OK", async () => {
|
|
||||||
// create one session for testing
|
|
||||||
const payload0 = {
|
|
||||||
"cmd": "sessions.create"
|
|
||||||
}
|
|
||||||
const response0: Response = await request(app).post("/v1").send(payload0);
|
|
||||||
expect(response0.statusCode).toBe(200);
|
|
||||||
const apiResponse0: V1ResponseSession = response0.body;
|
|
||||||
const sessionId0 = apiResponse0.session
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
"cmd": "sessions.destroy",
|
|
||||||
"session": sessionId0
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
expect(apiResponse.message).toBe("The session has been removed.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThanOrEqual(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'sessions.destroy' should fail", async () => {
|
|
||||||
const payload = {
|
|
||||||
"cmd": "sessions.destroy",
|
|
||||||
"session": "bad-session"
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(500);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseBase = response.body;
|
|
||||||
expect(apiResponse.status).toBe("error");
|
|
||||||
expect(apiResponse.message).toBe("Error: This session does not exist.");
|
|
||||||
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
|
||||||
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
|
||||||
expect(apiResponse.version).toBe(version);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Cmd 'request.get' should use session", async () => {
|
|
||||||
// create one session for testing
|
|
||||||
const payload0 = {
|
|
||||||
"cmd": "sessions.create"
|
|
||||||
}
|
|
||||||
const response0: Response = await request(app).post("/v1").send(payload0);
|
|
||||||
expect(response0.statusCode).toBe(200);
|
|
||||||
const apiResponse0: V1ResponseSession = response0.body;
|
|
||||||
const sessionId0 = apiResponse0.session
|
|
||||||
|
|
||||||
// first request should solve the challenge
|
|
||||||
const payload = {
|
|
||||||
"cmd": "request.get",
|
|
||||||
"url": cfUrl,
|
|
||||||
"session": sessionId0
|
|
||||||
}
|
|
||||||
const response: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse: V1ResponseSolution = response.body;
|
|
||||||
expect(apiResponse.status).toBe("ok");
|
|
||||||
const cfCookie: string = (apiResponse.solution.cookies as any[]).filter(function(cookie) {
|
|
||||||
return cookie.name == "cf_clearance";
|
|
||||||
})[0].value
|
|
||||||
expect(cfCookie.length).toBeGreaterThan(30)
|
|
||||||
|
|
||||||
// second request should have the same cookie
|
|
||||||
const response2: Response = await request(app).post("/v1").send(payload);
|
|
||||||
expect(response2.statusCode).toBe(200);
|
|
||||||
|
|
||||||
const apiResponse2: V1ResponseSolution = response2.body;
|
|
||||||
expect(apiResponse2.status).toBe("ok");
|
|
||||||
const cfCookie2: string = (apiResponse2.solution.cookies as any[]).filter(function(cookie) {
|
|
||||||
return cookie.name == "cf_clearance";
|
|
||||||
})[0].value
|
|
||||||
expect(cfCookie2.length).toBeGreaterThan(30)
|
|
||||||
expect(cfCookie2).toBe(cfCookie)
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
102
src/tests_sites.py
Normal file
102
src/tests_sites.py
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from webtest import TestApp
|
||||||
|
|
||||||
|
from dtos import V1ResponseBase, STATUS_OK
|
||||||
|
import flaresolverr
|
||||||
|
import utils
|
||||||
|
|
||||||
|
|
||||||
|
def _find_obj_by_key(key: str, value: str, _list: list) -> dict | None:
|
||||||
|
for obj in _list:
|
||||||
|
if obj[key] == value:
|
||||||
|
return obj
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def asset_cloudflare_solution(self, res, site_url, site_text):
|
||||||
|
self.assertEqual(res.status_code, 200)
|
||||||
|
|
||||||
|
body = V1ResponseBase(res.json)
|
||||||
|
self.assertEqual(STATUS_OK, body.status)
|
||||||
|
self.assertEqual("Challenge solved!", body.message)
|
||||||
|
self.assertGreater(body.startTimestamp, 10000)
|
||||||
|
self.assertGreaterEqual(body.endTimestamp, body.startTimestamp)
|
||||||
|
self.assertEqual(utils.get_flaresolverr_version(), body.version)
|
||||||
|
|
||||||
|
solution = body.solution
|
||||||
|
self.assertIn(site_url, solution.url)
|
||||||
|
self.assertEqual(solution.status, 200)
|
||||||
|
self.assertIs(len(solution.headers), 0)
|
||||||
|
self.assertIn(site_text, solution.response)
|
||||||
|
self.assertGreater(len(solution.cookies), 0)
|
||||||
|
self.assertIn("Chrome/", solution.userAgent)
|
||||||
|
|
||||||
|
cf_cookie = _find_obj_by_key("name", "cf_clearance", solution.cookies)
|
||||||
|
self.assertIsNotNone(cf_cookie, "Cloudflare cookie not found")
|
||||||
|
self.assertGreater(len(cf_cookie["value"]), 30)
|
||||||
|
|
||||||
|
|
||||||
|
class TestFlareSolverr(unittest.TestCase):
|
||||||
|
app = TestApp(flaresolverr.app)
|
||||||
|
# wait until the server is ready
|
||||||
|
app.get('/')
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_get_cloudflare(self):
|
||||||
|
sites_get = [
|
||||||
|
('nowsecure', 'https://nowsecure.nl', '<title>nowSecure</title>'),
|
||||||
|
('0magnet', 'https://0magnet.com/search?q=2022', 'Torrent Search - ØMagnet'),
|
||||||
|
('1337x', 'https://1337x.unblockit.cat/cat/Movies/time/desc/1/', ''),
|
||||||
|
('avistaz', 'https://avistaz.to/api/v1/jackett/torrents?in=1&type=0&search=',
|
||||||
|
'<title>Access denied</title>'),
|
||||||
|
('badasstorrents', 'https://badasstorrents.com/torrents/search/720p/date/desc',
|
||||||
|
'<title>Latest Torrents - BadassTorrents</title>'),
|
||||||
|
('bt4g', 'https://bt4g.org/search/2022', '<title>Download 2022 Torrents - BT4G</title>'),
|
||||||
|
('cinemaz', 'https://cinemaz.to/api/v1/jackett/torrents?in=1&type=0&search=',
|
||||||
|
'<title>Access denied</title>'),
|
||||||
|
('epublibre', 'https://epublibre.unblockit.cat/catalogo/index/0/nuevo/todos/sin/todos/--/ajax',
|
||||||
|
'<title>epublibre - catálogo</title>'),
|
||||||
|
('ext', 'https://ext.to/latest/?order=age&sort=desc',
|
||||||
|
'<title>Download Latest Torrents - EXT Torrents</title>'),
|
||||||
|
('extratorrent', 'https://extratorrent.st/search/?srt=added&order=desc&search=720p&new=1&x=0&y=0',
|
||||||
|
'Page 1 - ExtraTorrent'),
|
||||||
|
('idope', 'https://idope.se/browse.html', '<title>Recent Torrents</title>'),
|
||||||
|
('limetorrents', 'https://limetorrents.unblockninja.com/latest100',
|
||||||
|
'<title>Latest 100 torrents - LimeTorrents</title>'),
|
||||||
|
('privatehd', 'https://privatehd.to/api/v1/jackett/torrents?in=1&type=0&search=',
|
||||||
|
'<title>Access denied</title>'),
|
||||||
|
('torrentcore', 'https://torrentcore.xyz/index', '<title>Torrent[CORE] - Torrent community.</title>'),
|
||||||
|
('torrentqq223', 'https://torrentqq223.com/torrent/newest.html', 'https://torrentqq223.com/ads/'),
|
||||||
|
('36dm', 'https://www.36dm.club/1.html', 'https://www.36dm.club/yesterday-1.html'),
|
||||||
|
('erai-raws', 'https://www.erai-raws.info/feed/?type=magnet', '403 Forbidden'),
|
||||||
|
('teamos', 'https://www.teamos.xyz/torrents/?filename=&freeleech=',
|
||||||
|
'<title>Log in | Team OS : Your Only Destination To Custom OS !!</title>'),
|
||||||
|
('yts', 'https://yts.unblockninja.com/api/v2/list_movies.json?query_term=&limit=50&sort=date_added',
|
||||||
|
'{"movie_count":')
|
||||||
|
]
|
||||||
|
for site_name, site_url, site_text in sites_get:
|
||||||
|
with self.subTest(msg=site_name):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": site_url
|
||||||
|
})
|
||||||
|
asset_cloudflare_solution(self, res, site_url, site_text)
|
||||||
|
|
||||||
|
def test_v1_endpoint_request_post_cloudflare(self):
|
||||||
|
sites_post = [
|
||||||
|
('nnmclub', 'https://nnmclub.to/forum/tracker.php', '<title>Трекер :: NNM-Club</title>',
|
||||||
|
'prev_sd=0&prev_a=0&prev_my=0&prev_n=0&prev_shc=0&prev_shf=1&prev_sha=1&prev_shs=0&prev_shr=0&prev_sht=0&f%5B%5D=-1&o=1&s=2&tm=-1&shf=1&sha=1&ta=-1&sns=-1&sds=-1&nm=&pn=&submit=%CF%EE%E8%F1%EA')
|
||||||
|
]
|
||||||
|
|
||||||
|
for site_name, site_url, site_text, post_data in sites_post:
|
||||||
|
with self.subTest(msg=site_name):
|
||||||
|
res = self.app.post_json('/v1', {
|
||||||
|
"cmd": "request.post",
|
||||||
|
"url": site_url,
|
||||||
|
"postData": post_data
|
||||||
|
})
|
||||||
|
asset_cloudflare_solution(self, res, site_url, site_text)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
348
src/utils.py
Normal file
348
src/utils.py
Normal file
@@ -0,0 +1,348 @@
|
|||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import urllib.parse
|
||||||
|
import tempfile
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from DrissionPage import ChromiumPage, ChromiumOptions
|
||||||
|
# from DrissionPage.common import Settings
|
||||||
|
|
||||||
|
FLARESOLVERR_VERSION = None
|
||||||
|
PLATFORM_VERSION = None
|
||||||
|
CHROME_MAJOR_VERSION = None
|
||||||
|
XVFB_DISPLAY = None
|
||||||
|
|
||||||
|
CHROME_EXE_PATH = os.environ.get('CHROME_EXE_PATH', None)
|
||||||
|
USER_AGENT = os.environ.get('USER_AGENT', None)
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_log_html() -> bool:
|
||||||
|
return os.environ.get('LOG_HTML', 'false').lower() == 'true'
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_headless() -> bool:
|
||||||
|
return os.environ.get('HEADLESS', 'true').lower() == 'true'
|
||||||
|
|
||||||
|
|
||||||
|
def get_flaresolverr_version() -> str:
|
||||||
|
global FLARESOLVERR_VERSION
|
||||||
|
if FLARESOLVERR_VERSION is not None:
|
||||||
|
return FLARESOLVERR_VERSION
|
||||||
|
|
||||||
|
package_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'package.json')
|
||||||
|
if not os.path.isfile(package_path):
|
||||||
|
package_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'package.json')
|
||||||
|
with open(package_path) as f:
|
||||||
|
FLARESOLVERR_VERSION = json.loads(f.read())['version']
|
||||||
|
return FLARESOLVERR_VERSION
|
||||||
|
|
||||||
|
def get_current_platform() -> str:
|
||||||
|
global PLATFORM_VERSION
|
||||||
|
if PLATFORM_VERSION is not None:
|
||||||
|
return PLATFORM_VERSION
|
||||||
|
PLATFORM_VERSION = os.name
|
||||||
|
return PLATFORM_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
def create_proxy_extension(proxy: dict) -> str:
|
||||||
|
parsed_url = urllib.parse.urlparse(proxy['url'])
|
||||||
|
scheme = parsed_url.scheme
|
||||||
|
host = parsed_url.hostname
|
||||||
|
port = parsed_url.port
|
||||||
|
username = proxy['username']
|
||||||
|
password = proxy['password']
|
||||||
|
manifest_json = """
|
||||||
|
{
|
||||||
|
"version": "1.0.0",
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "Chrome Proxy",
|
||||||
|
"permissions": [
|
||||||
|
"proxy",
|
||||||
|
"tabs",
|
||||||
|
"unlimitedStorage",
|
||||||
|
"storage",
|
||||||
|
"<all_urls>",
|
||||||
|
"webRequest",
|
||||||
|
"webRequestBlocking"
|
||||||
|
],
|
||||||
|
"background": {"scripts": ["background.js"]},
|
||||||
|
"minimum_chrome_version": "76.0.0"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
background_js = """
|
||||||
|
var config = {
|
||||||
|
mode: "fixed_servers",
|
||||||
|
rules: {
|
||||||
|
singleProxy: {
|
||||||
|
scheme: "%s",
|
||||||
|
host: "%s",
|
||||||
|
port: %d
|
||||||
|
},
|
||||||
|
bypassList: ["localhost"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
|
||||||
|
|
||||||
|
function callbackFn(details) {
|
||||||
|
return {
|
||||||
|
authCredentials: {
|
||||||
|
username: "%s",
|
||||||
|
password: "%s"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.webRequest.onAuthRequired.addListener(
|
||||||
|
callbackFn,
|
||||||
|
{ urls: ["<all_urls>"] },
|
||||||
|
['blocking']
|
||||||
|
);
|
||||||
|
""" % (
|
||||||
|
scheme,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
)
|
||||||
|
|
||||||
|
proxy_extension_dir = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
with open(os.path.join(proxy_extension_dir, "manifest.json"), "w") as f:
|
||||||
|
f.write(manifest_json)
|
||||||
|
|
||||||
|
with open(os.path.join(proxy_extension_dir, "background.js"), "w") as f:
|
||||||
|
f.write(background_js)
|
||||||
|
|
||||||
|
return proxy_extension_dir
|
||||||
|
|
||||||
|
|
||||||
|
def get_webdriver(proxy: dict = None) -> ChromiumPage:
|
||||||
|
global CHROME_EXE_PATH, USER_AGENT
|
||||||
|
logging.debug('Launching web browser...')
|
||||||
|
|
||||||
|
# undetected_chromedriver
|
||||||
|
options = ChromiumOptions()
|
||||||
|
options.set_argument('--no-sandbox')
|
||||||
|
options.set_argument('--window-size=1920,1080')
|
||||||
|
# todo: this param shows a warning in chrome head-full
|
||||||
|
options.set_argument('--disable-setuid-sandbox')
|
||||||
|
options.set_argument('--disable-dev-shm-usage')
|
||||||
|
# this option removes the zygote sandbox (it seems that the resolution is a bit faster)
|
||||||
|
options.set_argument('--no-zygote')
|
||||||
|
# attempt to fix Docker ARM32 build
|
||||||
|
options.set_argument('--disable-gpu-sandbox')
|
||||||
|
options.set_argument('--disable-software-rasterizer')
|
||||||
|
options.set_argument('--ignore-certificate-errors')
|
||||||
|
options.set_argument('--ignore-ssl-errors')
|
||||||
|
# fix GL errors in ASUSTOR NAS
|
||||||
|
# https://github.com/FlareSolverr/FlareSolverr/issues/782
|
||||||
|
# https://github.com/microsoft/vscode/issues/127800#issuecomment-873342069
|
||||||
|
# https://peter.sh/experiments/chromium-command-line-switches/#use-gl
|
||||||
|
options.set_argument('--use-gl=swiftshader')
|
||||||
|
|
||||||
|
language = os.environ.get('LANG', None)
|
||||||
|
if language is not None:
|
||||||
|
options.set_argument('--accept-lang=%s' % language)
|
||||||
|
|
||||||
|
# Fix for Chrome 117 | https://github.com/FlareSolverr/FlareSolverr/issues/910
|
||||||
|
if USER_AGENT is not None:
|
||||||
|
options.set_argument('--user-agent=%s' % USER_AGENT)
|
||||||
|
|
||||||
|
proxy_extension_dir = None
|
||||||
|
if proxy and all(key in proxy for key in ['url', 'username', 'password']):
|
||||||
|
proxy_extension_dir = create_proxy_extension(proxy)
|
||||||
|
options.set_argument("--load-extension=%s" % os.path.abspath(proxy_extension_dir))
|
||||||
|
elif proxy and 'url' in proxy:
|
||||||
|
proxy_url = proxy['url']
|
||||||
|
logging.debug("Using webdriver proxy: %s", proxy_url)
|
||||||
|
options.set_argument('--proxy-server=%s' % proxy_url)
|
||||||
|
|
||||||
|
windows_headless = False
|
||||||
|
if get_config_headless():
|
||||||
|
if os.name == 'nt':
|
||||||
|
windows_headless = True
|
||||||
|
else:
|
||||||
|
start_xvfb_display()
|
||||||
|
options.headless(windows_headless)
|
||||||
|
options.set_argument("--auto-open-devtools-for-tabs")
|
||||||
|
|
||||||
|
if CHROME_EXE_PATH is not None:
|
||||||
|
options.set_paths(browser_path=CHROME_EXE_PATH)
|
||||||
|
|
||||||
|
# clean up proxy extension directory
|
||||||
|
if proxy_extension_dir is not None:
|
||||||
|
shutil.rmtree(proxy_extension_dir)
|
||||||
|
|
||||||
|
driver = ChromiumPage(addr_or_opts=options)
|
||||||
|
|
||||||
|
return driver
|
||||||
|
|
||||||
|
|
||||||
|
def get_chrome_exe_path() -> str:
|
||||||
|
global CHROME_EXE_PATH
|
||||||
|
if CHROME_EXE_PATH is not None:
|
||||||
|
return CHROME_EXE_PATH
|
||||||
|
# linux pyinstaller bundle
|
||||||
|
chrome_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'chrome', "chrome")
|
||||||
|
if os.path.exists(chrome_path):
|
||||||
|
if not os.access(chrome_path, os.X_OK):
|
||||||
|
raise Exception(f'Chrome binary "{chrome_path}" is not executable. '
|
||||||
|
f'Please, extract the archive with "tar xzf <file.tar.gz>".')
|
||||||
|
CHROME_EXE_PATH = chrome_path
|
||||||
|
return CHROME_EXE_PATH
|
||||||
|
# windows pyinstaller bundle
|
||||||
|
chrome_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'chrome', "chrome.exe")
|
||||||
|
if os.path.exists(chrome_path):
|
||||||
|
CHROME_EXE_PATH = chrome_path
|
||||||
|
return CHROME_EXE_PATH
|
||||||
|
# system
|
||||||
|
CHROME_EXE_PATH = find_chrome_executable()
|
||||||
|
return CHROME_EXE_PATH
|
||||||
|
|
||||||
|
|
||||||
|
def find_chrome_executable():
|
||||||
|
"""
|
||||||
|
Finds the chrome, chrome beta, chrome canary, chromium executable
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
executable_path : str
|
||||||
|
the full file path to found executable
|
||||||
|
|
||||||
|
"""
|
||||||
|
candidates = set()
|
||||||
|
if sys.platform.startswith(("darwin", "cygwin", "linux", "linux2", "freebsd")):
|
||||||
|
for item in os.environ.get("PATH").split(os.pathsep):
|
||||||
|
for subitem in (
|
||||||
|
"google-chrome",
|
||||||
|
"chromium",
|
||||||
|
"chromium-browser",
|
||||||
|
"chrome",
|
||||||
|
"google-chrome-stable",
|
||||||
|
):
|
||||||
|
candidates.add(os.sep.join((item, subitem)))
|
||||||
|
if "darwin" in sys.platform:
|
||||||
|
candidates.update(
|
||||||
|
[
|
||||||
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||||
|
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for item in map(
|
||||||
|
os.environ.get,
|
||||||
|
("PROGRAMFILES", "PROGRAMFILES(X86)", "LOCALAPPDATA", "PROGRAMW6432"),
|
||||||
|
):
|
||||||
|
if item is not None:
|
||||||
|
for subitem in (
|
||||||
|
"Google/Chrome/Application",
|
||||||
|
):
|
||||||
|
candidates.add(os.sep.join((item, subitem, "chrome.exe")))
|
||||||
|
for candidate in candidates:
|
||||||
|
if os.path.exists(candidate) and os.access(candidate, os.X_OK):
|
||||||
|
return os.path.normpath(candidate)
|
||||||
|
|
||||||
|
|
||||||
|
def get_chrome_major_version() -> str:
|
||||||
|
global CHROME_MAJOR_VERSION
|
||||||
|
if CHROME_MAJOR_VERSION is not None:
|
||||||
|
return CHROME_MAJOR_VERSION
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
# Example: '104.0.5112.79'
|
||||||
|
try:
|
||||||
|
complete_version = extract_version_nt_executable(get_chrome_exe_path())
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
complete_version = extract_version_nt_registry()
|
||||||
|
except Exception:
|
||||||
|
# Example: '104.0.5112.79'
|
||||||
|
complete_version = extract_version_nt_folder()
|
||||||
|
else:
|
||||||
|
chrome_path = get_chrome_exe_path()
|
||||||
|
process = os.popen(f'"{chrome_path}" --version')
|
||||||
|
# Example 1: 'Chromium 104.0.5112.79 Arch Linux\n'
|
||||||
|
# Example 2: 'Google Chrome 104.0.5112.79 Arch Linux\n'
|
||||||
|
complete_version = process.read()
|
||||||
|
process.close()
|
||||||
|
|
||||||
|
CHROME_MAJOR_VERSION = complete_version.split('.')[0].split(' ')[-1]
|
||||||
|
return CHROME_MAJOR_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
def extract_version_nt_executable(exe_path: str) -> str:
|
||||||
|
import pefile
|
||||||
|
pe = pefile.PE(exe_path, fast_load=True)
|
||||||
|
pe.parse_data_directories(
|
||||||
|
directories=[pefile.DIRECTORY_ENTRY["IMAGE_DIRECTORY_ENTRY_RESOURCE"]]
|
||||||
|
)
|
||||||
|
return pe.FileInfo[0][0].StringTable[0].entries[b"FileVersion"].decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
|
def extract_version_nt_registry() -> str:
|
||||||
|
stream = os.popen(
|
||||||
|
'reg query "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"')
|
||||||
|
output = stream.read()
|
||||||
|
google_version = ''
|
||||||
|
for letter in output[output.rindex('DisplayVersion REG_SZ') + 24:]:
|
||||||
|
if letter != '\n':
|
||||||
|
google_version += letter
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return google_version.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def extract_version_nt_folder() -> str:
|
||||||
|
# Check if the Chrome folder exists in the x32 or x64 Program Files folders.
|
||||||
|
for i in range(2):
|
||||||
|
path = 'C:\\Program Files' + (' (x86)' if i else '') + '\\Google\\Chrome\\Application'
|
||||||
|
if os.path.isdir(path):
|
||||||
|
paths = [f.path for f in os.scandir(path) if f.is_dir()]
|
||||||
|
for path in paths:
|
||||||
|
filename = os.path.basename(path)
|
||||||
|
pattern = '\d+\.\d+\.\d+\.\d+'
|
||||||
|
match = re.search(pattern, filename)
|
||||||
|
if match and match.group():
|
||||||
|
# Found a Chrome version.
|
||||||
|
return match.group(0)
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def get_user_agent(driver=None) -> str:
|
||||||
|
global USER_AGENT
|
||||||
|
if USER_AGENT is not None:
|
||||||
|
return USER_AGENT
|
||||||
|
|
||||||
|
try:
|
||||||
|
if driver is None:
|
||||||
|
driver = get_webdriver()
|
||||||
|
USER_AGENT = driver.user_agent
|
||||||
|
# Fix for Chrome 117 | https://github.com/FlareSolverr/FlareSolverr/issues/910
|
||||||
|
USER_AGENT = re.sub('HEADLESS', '', USER_AGENT, flags=re.IGNORECASE)
|
||||||
|
return USER_AGENT
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("Error getting browser User-Agent. " + str(e))
|
||||||
|
finally:
|
||||||
|
if driver is not None:
|
||||||
|
if PLATFORM_VERSION == "nt":
|
||||||
|
driver.close()
|
||||||
|
driver.quit()
|
||||||
|
|
||||||
|
|
||||||
|
def start_xvfb_display():
|
||||||
|
global XVFB_DISPLAY
|
||||||
|
if XVFB_DISPLAY is None:
|
||||||
|
from xvfbwrapper import Xvfb
|
||||||
|
XVFB_DISPLAY = Xvfb()
|
||||||
|
XVFB_DISPLAY.start()
|
||||||
|
|
||||||
|
|
||||||
|
def object_to_dict(_object):
|
||||||
|
json_dict = json.loads(json.dumps(_object, default=lambda o: o.__dict__))
|
||||||
|
# remove hidden fields
|
||||||
|
return {k: v for k, v in json_dict.items() if not k.startswith('__')}
|
||||||
1
test-requirements.txt
Normal file
1
test-requirements.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
WebTest==3.0.0
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"target": "es2017",
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"removeComments": true,
|
|
||||||
"preserveConstEnums": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"lib": [
|
|
||||||
"es2015", "dom"
|
|
||||||
],
|
|
||||||
"module": "commonjs",
|
|
||||||
"outDir": "dist",
|
|
||||||
"sourceMap": true
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src", "node_modules/@types/puppeteer/index.d.ts"
|
|
||||||
],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user