-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c2dc76
commit 8c184a1
Showing
2 changed files
with
10 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
from src.tools.config import Config | ||
|
||
proxy = Config.bot_basic.proxy | ||
|
||
import httpx | ||
|
||
async def get_url(url, **kwargs): | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False) as client: | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False, proxy=proxy) as client: | ||
resp = await client.get(url, **kwargs) | ||
result = resp.text | ||
return result | ||
|
||
async def get_content(url, **kwargs): | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False) as client: | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False, proxy=proxy) as client: | ||
resp = await client.get(url, **kwargs) | ||
result = resp.content | ||
return result | ||
|
||
async def get_status(url, **kwargs): | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False) as client: | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False, proxy=proxy) as client: | ||
resp = await client.get(url, **kwargs) | ||
result = resp.status_code | ||
return result | ||
|
||
async def get_api(url, **kwargs): | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False) as client: | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False, proxy=proxy) as client: | ||
resp = await client.get(url, **kwargs) | ||
result = resp.json() | ||
return result | ||
|
||
async def post_url(url, **kwargs): | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False) as client: | ||
async with httpx.AsyncClient(follow_redirects=True, verify=False, proxy=proxy) as client: | ||
resp = await client.post(url, **kwargs) | ||
result = resp.text | ||
return result |