## 1) please remove numbers from names list so it fits into dataframe
## 2) also why does this return zero print(soup.content)
import bs4
import requests
result = requests.get(‘https://aoestats.io/stats’)
soup = bs4.BeautifulSoup(result.text, “html.parser”)
print(soup.content)
names = []
for link in soup.select(‘#civ-stats-body td’):
names.append(link.text)
for i in range(len(names)):
names[i]=names[i].replace(“n”,””)   
average_game_length=[]
k=1
for i in range(len(names)):
if(k%9==0):
average_game_length.append(names[i])
else:
pass
k=k+1
print(len(average_game_length))
print(len(names))
print(names)   
import pandas as pd
cols = [‘names’, ‘average_game_length’]
dicty = {cols[0]:names, cols[1]:average_game_length}
df = pd.DataFrame(dicty)   

print(df.head())



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *