From 86a4b18a59bbfd095b072ffd6c6b1ab185d515ed Mon Sep 17 00:00:00 2001 From: Sindre Kjelsrud Date: Mon, 8 Jan 2024 15:14:05 +0100 Subject: [PATCH] :art: add config file Co-authored-by: haraldnilsen Signed-off-by: Sindre Kjelsrud --- config.py | 3 +++ main.py | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..ead744f --- /dev/null +++ b/config.py @@ -0,0 +1,3 @@ +headers = { + "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0" +} \ No newline at end of file diff --git a/main.py b/main.py index e3b2728..26c52f3 100644 --- a/main.py +++ b/main.py @@ -2,13 +2,11 @@ import httpx from selectolax.parser import HTMLParser import re import csv +import config def fetch_question_url(url): # Define headers - headers = { - "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0" - } - + headers = config.headers # Define the parameters for the request params = { "action": "get-faqs", @@ -40,9 +38,7 @@ def fetch_question_url(url): def fetch_all_info(url): # Define headers - headers = { - "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0" - } + headers = config.headers response = httpx.get(url, headers=headers) html = HTMLParser(response.text)