generated from Hazel/python-project
Compare commits
No commits in common. "36829906d026aab7e486a15334732a1975daa13d" and "9f9ce9bd891102779704a0f5851488bff5404211" have entirely different histories.
36829906d0
...
9f9ce9bd89
1
.gitignore
vendored
1
.gitignore
vendored
@ -160,4 +160,3 @@ cython_debug/
|
|||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
cache
|
|
||||||
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"cSpell.words": [
|
|
||||||
"referer"
|
|
||||||
]
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ A Python library for simplified HTTP requests, featuring rate limiting, browser-
|
|||||||
## ToDo
|
## ToDo
|
||||||
|
|
||||||
- [ ] basic structure
|
- [ ] basic structure
|
||||||
- [ ] caching
|
|
||||||
- [ ] add cloudscraper
|
- [ ] add cloudscraper
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -4,5 +4,3 @@ import pathlib
|
|||||||
__name__ = "python_requests"
|
__name__ = "python_requests"
|
||||||
__folder__ = str(pathlib.Path(__file__).parent)
|
__folder__ = str(pathlib.Path(__file__).parent)
|
||||||
|
|
||||||
|
|
||||||
CACHE_DIRECTORY = "cache"
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .connections import Connection
|
|
||||||
|
|
||||||
|
|
||||||
def cli():
|
def cli():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -32,12 +30,5 @@ def cli():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
c = Connection()
|
|
||||||
c.generate_headers()
|
|
||||||
print(c.session.headers)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
from __future__ import annotations
|
|
||||||
from typing import Optional
|
|
||||||
import requests
|
|
||||||
from urllib.parse import urlparse, urlunsplit, ParseResult
|
|
||||||
|
|
||||||
|
|
||||||
class Connection:
|
|
||||||
def __init__(self, session: Optional[requests.Session] = None) -> None:
|
|
||||||
self.session = session if session is not None else requests.Session()
|
|
||||||
|
|
||||||
def generate_headers(self, referer: Optional[str] = None):
|
|
||||||
headers = {
|
|
||||||
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0",
|
|
||||||
"Connection": "keep-alive",
|
|
||||||
"Accept-Language": "en-US,en;q=0.5",
|
|
||||||
}
|
|
||||||
|
|
||||||
if referer is not None:
|
|
||||||
headers["Referer"] = referer
|
|
||||||
|
|
||||||
self.session.headers.update(**headers)
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user