Commit ccbf5c09 authored by nanahira's avatar nanahira

add cookie file

parent e4fa6fd3
Pipeline #22558 passed with stages
in 29 seconds
......@@ -32,8 +32,12 @@ privateKey = os.getenv('TWITTER_AUTH_KEY')
if privateKey:
twitterKeys = privateKey.split(" ")
cookie = os.getenv('COOKIE')
csrf = os.getenv('CSRF')
cookies = [os.getenv('COOKIE')]
cookie_file = os.getenv('COOKIE_FILE')
if cookie_file:
with open(cookie_file, 'r') as f:
cookies = str.strip(f.read()).split("\n")
print("Booting")
ENDPOINT = {
......@@ -73,9 +77,10 @@ def getTwitterSession(useCookie):
twitter_b = OAuth2Session()
twitter_b.headers["Authorization"] = "Bearer {}".format(random.choice(twitterKeys))
twitter_b.headers['user-agent'] = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
if cookie and csrf: # and useCookie:
cookie = random.choice(cookies)
if cookie: # and useCookie:
twitter_b.headers['cookie'] = cookie
twitter_b.headers['x-csrf-token'] = csrf
twitter_b.headers['x-csrf-token'] = cookie.split("ct0=")[1].split(";")[0]
return twitter_b
def doSearch(screen_name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment