Load cookies from cookies.txt
This commit is contained in:
parent
5aa747ea85
commit
7111d3cfcb
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
venv
|
||||
.venv
|
||||
__pycache__
|
||||
__pycache__
|
||||
cookies.txt
|
9
app.py
9
app.py
|
@ -1,12 +1,21 @@
|
|||
import http.cookiejar
|
||||
from flask import Flask, Response
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
cookie_jar = http.cookiejar.MozillaCookieJar('cookies.txt')
|
||||
try:
|
||||
cookie_jar.load(ignore_discard=True, ignore_expires=True)
|
||||
except FileNotFoundError:
|
||||
print("cookies.txt not found, starting with empty cookie jar")
|
||||
|
||||
s = requests.Session()
|
||||
s.headers.update({
|
||||
"User-Agent": "Twitterbot/1.0"
|
||||
})
|
||||
s.cookies = cookie_jar # type: ignore
|
||||
|
||||
@app.route("/watch/<video_id>")
|
||||
def proxy(video_id):
|
||||
|
|
Loading…
Reference in New Issue
Block a user