Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ jobs:
REPOSITORY: ${{ github.repository }}
REF_BRANCH: "legacy-twitter"
READ_SCRIPT_JSON: "True"
PROXY_LIST: ${{ secrets.PROXY_LIST }}
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
REPOSITORY: ${{ github.repository }}
BASE_BRANCH: "master"
REF_BRANCH: "develop"
PROXY_LIST: ${{ secrets.PROXY_LIST }}
- name: Run Python (Deck)
run: python generator.py
env:
Expand All @@ -58,3 +59,4 @@ jobs:
REF_BRANCH: "develop"
CLIENT_TYPE: Deck
OUTPUT_DIR: docs/deck
PROXY_LIST: ${{ secrets.PROXY_LIST }}
7 changes: 7 additions & 0 deletions lib/twitter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os
import random
import re

import requests
Expand All @@ -14,6 +16,11 @@ class TwitterHome:

def __init__(self):
self.session = requests.session()
proxies = [x.strip() for x in os.environ.get("PROXY_LIST", "").splitlines() if x.strip()]
if proxies:
host, port, username, password = random.choice(proxies).split(":")
proxy = f"http://{username}:{password}@{host}:{port}"
self.session.proxies = {"http": proxy, "https": proxy}
self.user_agent = self.session.get(
self.LATEST_USER_AGENT, timeout=self.TIMEOUT
).json()["chrome"]
Expand Down
Loading