Skip to content

Instantly share code, notes, and snippets.

@Nekodigi
Created September 11, 2020 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nekodigi/0770e4a920a4290ba5bd0afdc497d6d9 to your computer and use it in GitHub Desktop.
Save Nekodigi/0770e4a920a4290ba5bd0afdc497d6d9 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
import pandas as pd
import csv
userName = "Nekodigi"
urlName = "https://plancke.io/hypixel/player/stats/"+userName+"#Arcade"
url = requests.get(urlName)
soup = BeautifulSoup(url.content, "html.parser")
table = soup.find_all("table")
tab = table[0]
table_className = tab.get("class")
print(table_className)
with open("test.csv", "w", encoding='utf-8') as file:
writer = csv.writer(file)
rows = tab.find_all("tr")
for row in rows:
csvRow = []
for cell in row.findAll(['td', 'th']):
csvRow.append(cell.get_text())
writer.writerow(csvRow)
pd.read_csv("test.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment