mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Enable ruff S113 rule (#11375)
* Enable ruff S113 rule * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -12,7 +12,7 @@ def save_image(image_url: str, image_title: str) -> None:
|
||||
"""
|
||||
Saves the image of anime character
|
||||
"""
|
||||
image = requests.get(image_url, headers=headers)
|
||||
image = requests.get(image_url, headers=headers, timeout=10)
|
||||
with open(image_title, "wb") as file:
|
||||
file.write(image.content)
|
||||
|
||||
@ -21,7 +21,9 @@ def random_anime_character() -> tuple[str, str, str]:
|
||||
"""
|
||||
Returns the Title, Description, and Image Title of a random anime character .
|
||||
"""
|
||||
soup = BeautifulSoup(requests.get(URL, headers=headers).text, "html.parser")
|
||||
soup = BeautifulSoup(
|
||||
requests.get(URL, headers=headers, timeout=10).text, "html.parser"
|
||||
)
|
||||
title = soup.find("meta", attrs={"property": "og:title"}).attrs["content"]
|
||||
image_url = soup.find("meta", attrs={"property": "og:image"}).attrs["content"]
|
||||
description = soup.find("p", id="description").get_text()
|
||||
|
Reference in New Issue
Block a user