Skip to content

Commit d63654f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c24c1e2 commit d63654f

11 files changed

+31
-11
lines changed

machine_learning/linear_regression.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def collect_dataset():
2020
response = requests.get(
2121
"https://raw.githubusercontent.com/yashLadha/The_Math_of_Intelligence/"
2222
"master/Week1/ADRvsRating.csv",
23-
timeout=10
23+
timeout=10,
2424
)
2525
lines = response.text.splitlines()
2626
data = []

web_programming/covid_stats_via_xpath.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class CovidData(NamedTuple):
1818

1919
def covid_stats(url: str = "https://www.worldometers.info/coronavirus/") -> CovidData:
2020
xpath_str = '//div[@class = "maincounter-number"]/span/text()'
21-
return CovidData(*html.fromstring(requests.get(url, timeout=10).content).xpath(xpath_str))
21+
return CovidData(
22+
*html.fromstring(requests.get(url, timeout=10).content).xpath(xpath_str)
23+
)
2224

2325

2426
fmt = """Total COVID-19 cases in the world: {}

web_programming/crawl_google_scholar_citation.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def get_citation(base_url: str, params: dict) -> str:
1111
"""
1212
Return the citation number.
1313
"""
14-
soup = BeautifulSoup(requests.get(base_url, params=params, timeout=10).content, "html.parser")
14+
soup = BeautifulSoup(
15+
requests.get(base_url, params=params, timeout=10).content, "html.parser"
16+
)
1517
div = soup.find("div", attrs={"class": "gs_ri"})
1618
anchors = div.find("div", attrs={"class": "gs_fl"}).find_all("a")
1719
return anchors[2].get_text()

web_programming/current_stock_price.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
def stock_price(symbol: str = "AAPL") -> str:
66
url = f"https://finance.yahoo.com/quote/{symbol}?p={symbol}"
7-
yahoo_finance_source = requests.get(url, headers={"USER-AGENT": "Mozilla/5.0"}, timeout=10).text
7+
yahoo_finance_source = requests.get(
8+
url, headers={"USER-AGENT": "Mozilla/5.0"}, timeout=10
9+
).text
810
soup = BeautifulSoup(yahoo_finance_source, "html.parser")
911
specific_fin_streamer_tag = soup.find("fin-streamer", {"data-test": "qsp-price"})
1012

web_programming/download_images_from_google_query.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def download_images_from_google_query(query: str = "dhaka", max_images: int = 5)
3939
"ijn": "0",
4040
}
4141

42-
html = requests.get("https://www.google.com/search", params=params, headers=headers, timeout=10)
42+
html = requests.get(
43+
"https://www.google.com/search", params=params, headers=headers, timeout=10
44+
)
4345
soup = BeautifulSoup(html.text, "html.parser")
4446
matched_images_data = "".join(
4547
re.findall(r"AF_initDataCallback\(([^<]+)\);", str(soup.select("script")))

web_programming/fetch_anime_and_play.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def search_anime_episode_list(episode_endpoint: str) -> list:
8282

8383
request_url = f"{BASE_URL}{episode_endpoint}"
8484

85-
response = requests.get(url=request_url, headers={"UserAgent": UserAgent().chrome}, timeout=10)
85+
response = requests.get(
86+
url=request_url, headers={"UserAgent": UserAgent().chrome}, timeout=10
87+
)
8688
response.raise_for_status()
8789

8890
soup = BeautifulSoup(response.text, "html.parser")

web_programming/fetch_jobs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414

1515
def fetch_jobs(location: str = "mumbai") -> Generator[tuple[str, str], None, None]:
16-
soup = BeautifulSoup(requests.get(url + location, timeout=10).content, "html.parser")
16+
soup = BeautifulSoup(
17+
requests.get(url + location, timeout=10).content, "html.parser"
18+
)
1719
# This attribute finds out all the specifics listed in a job
1820
for job in soup.find_all("div", attrs={"data-tn-component": "organicJob"}):
1921
job_title = job.find("a", attrs={"data-tn-element": "jobTitle"}).text.strip()

web_programming/get_amazon_product_data.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def get_amazon_product_data(product: str = "laptop") -> DataFrame:
2424
),
2525
"Accept-Language": "en-US, en;q=0.5",
2626
}
27-
soup = BeautifulSoup(requests.get(url, headers=header, timeout=10).text, features="lxml")
27+
soup = BeautifulSoup(
28+
requests.get(url, headers=header, timeout=10).text, features="lxml"
29+
)
2830
# Initialize a Pandas dataframe with the column titles
2931
data_frame = DataFrame(
3032
columns=[

web_programming/random_anime_character.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def random_anime_character() -> tuple[str, str, str]:
2121
"""
2222
Returns the Title, Description, and Image Title of a random anime character .
2323
"""
24-
soup = BeautifulSoup(requests.get(URL, headers=headers, timeout=10).text, "html.parser")
24+
soup = BeautifulSoup(
25+
requests.get(URL, headers=headers, timeout=10).text, "html.parser"
26+
)
2527
title = soup.find("meta", attrs={"property": "og:title"}).attrs["content"]
2628
image_url = soup.find("meta", attrs={"property": "og:image"}).attrs["content"]
2729
description = soup.find("p", id="description").get_text()

web_programming/recaptcha_verification.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def login_using_recaptcha(request):
5656
client_key = request.POST.get("g-recaptcha-response")
5757

5858
# post recaptcha response to Google's recaptcha api
59-
response = requests.post(url, data={"secret": secret_key, "response": client_key}, timeout=10)
59+
response = requests.post(
60+
url, data={"secret": secret_key, "response": client_key}, timeout=10
61+
)
6062
# if the recaptcha api verified our keys
6163
if response.json().get("success", False):
6264
# authenticate the user

web_programming/slack_message.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
def send_slack_message(message_body: str, slack_url: str) -> None:
77
headers = {"Content-Type": "application/json"}
8-
response = requests.post(slack_url, json={"text": message_body}, headers=headers, timeout=10)
8+
response = requests.post(
9+
slack_url, json={"text": message_body}, headers=headers, timeout=10
10+
)
911
if response.status_code != 200:
1012
msg = (
1113
"Request to slack returned an error "

0 commit comments

Comments
 (0)