Browse Source

Moved user-agent to web_methods

master
Abrax 3 years ago
parent
commit
8aa68fdd66
2 changed files with 4 additions and 4 deletions
  1. 0
    1
      constants.py
  2. 4
    3
      web_methods.py

+ 0
- 1
constants.py View File

@@ -1,2 +1 @@
user_agent = 'https://git.teknik.io/abrax/lizard'
conservative_refresh_criterion = 10

+ 4
- 3
web_methods.py View File

@@ -3,13 +3,14 @@ import re

import requests

import constants
import time_methods
from file_io import *
from file_io import generate_json_path
from json_methods import extract_filenames


user_agent = 'https://git.teknik.io/abrax/lizard'


def fetch_and_parse_thread_json(board, thread_no):
url = generate_thread_json_url(board, thread_no)
p = generate_json_path(board, thread_no)
@@ -60,7 +61,7 @@ def download_file(file_url, file_path):
""" If the request succeeds, downloads the file and returns True.

On a 404, returns False. On other responses, raises exception. """
r = requests.get(file_url, headers={'user-agent': constants.user_agent})
r = requests.get(file_url, headers={'user-agent': user_agent})

if r.status_code == requests.codes.ok:
save_file(file_path, r.content)

Loading…
Cancel
Save