sure
admititally its porly optimized
im a beginner so its a step in the right direction though
(python)
import requests
from bs4 import BeautifulSoup
import datetime
def Calculate_VLR_Avg(user):
url = f"https://www.vlr.gg/user/{user}"
response = requests.get(url)
print(response.status_code)
thing = response.text
soup =BeautifulSoup(thing, "html.parser")
idk = str( soup.find("table"))
idk = idk.replace(","," ")
what = idk.split()
while "<tr>" in what:
what.remove("<tr>")
what.remove("</tr>")
while "<td>" in what:
what.remove("<td>")
what.remove("</td>")
post_index = what.index("Posts:") + 1
posts = float(what[post_index])
print(posts)
today = datetime.date.today()
months = {
"January": "1", "February": "2", "March":"3",
"April":"4","May":"5","June":"6",
"July":"7","August":"8","September":"9",
"October":"10","November":"11","December":"12"
}
registerd_indexes = [what.index("Registered:") + 1,what.index("Registered:") + 2,what.index("Registered:") + 3]
year = int(what[registerd_indexes[2]])
month = what[registerd_indexes[0]]
for o_word, m_word in months.items():
month = month.replace(o_word, m_word)
month = int(month)
day = int(what[registerd_indexes[1]])
print(what[registerd_indexes[1]], month, what[registerd_indexes[2]])
diff = today - datetime.date(year,month,day)
day_diff = diff.days
print(day_diff)
hour_diff = day_diff *24
minute_diff = hour_diff * 60
second_diff = minute_diff * 60
day_avg = posts/day_diff
hour_avg = posts/hour_diff
minute_avg = posts/minute_diff
second_avg = posts/second_diff
print("\n\n\n")
print("```")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(
f"{user}'s stats: \n{user} posts = {round(posts)}, account age = {day_diff} days \n"
)
print("-----------------------------------------------------------------------")
print(f"{user} posts {round(day_avg,2)} times a day on average, \n{round(hour_avg,4)} times per hour on avg, \n{round(minute_avg,6)} times per minute on average, \nand {round(second_avg,6)} times a second on average")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("```")