-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Cloudscraper, fixed both stats sources, upgraded dependencies (#64
- Loading branch information
1 parent
b29a861
commit eb90fa3
Showing
6 changed files
with
98 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
aiomysql~=0.0.21 | ||
beautifulsoup4~=4.9.3 | ||
bitstring~=3.1.7 | ||
aiomysql~=0.1.1 | ||
beautifulsoup4~=4.11.2 | ||
bitstring~=4.0.1 | ||
cloudscraper~=1.2.69 | ||
discord.py~=1.7.1 | ||
flask~=1.1.2 | ||
flask~=2.2.3 | ||
fortnite-replay-reader~=0.3.0 | ||
pycryptodome~=3.10.1 | ||
python-dotenv~=0.17.0 | ||
requests~=2.25.1 | ||
pycryptodome~=3.17 | ||
python-dotenv~=1.0.0 | ||
requests~=2.28.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
from enum import Enum | ||
|
||
import cloudscraper | ||
|
||
|
||
class Method(Enum): | ||
""" Supported Cloudscrape methods. All request methods are | ||
technically supported. | ||
""" | ||
GET = "get" | ||
|
||
|
||
async def cloudscrape(method, url, headers, allow_redirects=True): | ||
""" Cloudscraper is used to bypass Cloudflare's bot detection. | ||
However, Cloudscraper does not support async so event loops are used. | ||
""" | ||
def _method(): | ||
scraper = cloudscraper.create_scraper() | ||
func = getattr(scraper, method.value) | ||
return func(url, headers=headers, allow_redirects=allow_redirects) | ||
|
||
return await asyncio.get_event_loop().run_in_executor( | ||
executor=None, | ||
func=_method | ||
) |