Add custom User-Agent

This commit is contained in:
Dave Gallant
2024-10-08 22:57:50 -04:00
parent 02415e5603
commit 58e9ac17b1
2 changed files with 5 additions and 1 deletions

View File

@@ -1 +1,3 @@
API_BASE_URL = "https://forums.redflagdeals.com"
HEADERS = {"User-Agent": "rfd-notify"}

View File

@@ -4,7 +4,7 @@ import re
import shelve
import requests
from loguru import logger
from constants import API_BASE_URL
from constants import API_BASE_URL, HEADERS
from config import Config
from notifications import send_notification
@@ -22,6 +22,7 @@ def get_topic(topic_id: int) -> List[Post]:
try:
response = requests.get(
f"{API_BASE_URL}/api/topics/{topic_id}/posts?per_page=1&page=1",
headers=HEADERS,
timeout=30,
)
if response.status_code != 200:
@@ -41,6 +42,7 @@ def get_topics(forum_id: int, pages: int) -> List[Topic]:
for page in range(1, pages + 1):
response = requests.get(
f"{API_BASE_URL}/api/topics?forum_id={forum_id}&per_page=40&page={page}",
headers=HEADERS,
timeout=30,
)
if response.status_code != 200: