mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Soupify requests responses properly
This commit is contained in:
@ -6,6 +6,7 @@ import logging
|
||||
from pathlib import Path, PurePath
|
||||
from typing import Optional, Tuple
|
||||
|
||||
import bs4
|
||||
import requests
|
||||
from colorama import Fore, Style
|
||||
|
||||
@ -30,6 +31,10 @@ def rename(path: PurePath, to_name: str) -> PurePath:
|
||||
return PurePath(*path.parts[:-1], to_name)
|
||||
|
||||
|
||||
def soupify(response: requests.Response) -> bs4.BeautifulSoup:
|
||||
return bs4.BeautifulSoup(response.text, "html.parser")
|
||||
|
||||
|
||||
def stream_to_path(response: requests.Response, to_path: Path, chunk_size: int = 1024 ** 2) -> None:
|
||||
"""
|
||||
Download a requests response content to a file by streaming it. This
|
||||
|
Reference in New Issue
Block a user