mirror of
https://github.com/SocksPls/hltv-api
synced 2025-04-30 15:43:07 +00:00
Update month to name function
Update month to name function to use the existing datetime import
This commit is contained in:
parent
a71ccc317e
commit
374c4f1b8e
1 changed files with 6 additions and 16 deletions
22
main.py
22
main.py
|
@ -34,22 +34,12 @@ def _padIfNeeded(numberStr: str):
|
||||||
return str(numberStr)
|
return str(numberStr)
|
||||||
|
|
||||||
def _monthNameToNumber(monthName: str):
|
def _monthNameToNumber(monthName: str):
|
||||||
months = {
|
# Check for the input "Augu" and convert it to "August"
|
||||||
'January': 1,
|
# This is necessary because the input string may have been sanitized
|
||||||
'February': 2,
|
# by removing the "st" from the day numbers, such as "21st" -> "21"
|
||||||
'March': 3,
|
if monthName == "Augu":
|
||||||
'April': 4,
|
monthName = "August"
|
||||||
'May': 5,
|
return datetime.strptime(monthName, '%B').month
|
||||||
'June': 6,
|
|
||||||
'July': 7,
|
|
||||||
'August': 8,
|
|
||||||
'Augu': 8,
|
|
||||||
'September': 9,
|
|
||||||
'October': 10,
|
|
||||||
'November': 11,
|
|
||||||
'December': 12
|
|
||||||
}
|
|
||||||
return months[monthName]
|
|
||||||
|
|
||||||
def get_parsed_page(url, delay=0.5):
|
def get_parsed_page(url, delay=0.5):
|
||||||
# This fixes a blocked by cloudflare error i've encountered
|
# This fixes a blocked by cloudflare error i've encountered
|
||||||
|
|
Loading…
Add table
Reference in a new issue