Reputation: 1
I want to extract various statistics from a website. Unfortunatley pandas does not recognize the tables presented. Here is my code:
url = 'https://u.gg/lol/champions/aurelionsol/matchups/'
html = requests.get(url).content
df_list = pd.read_html(html)
ValueError: No tables found
Thanks for the help in advance.
Upvotes: 0
Views: 994
Reputation: 11515
You can use API
directly.
import requests
r = requests.get(
'https://static.u.gg/assets/lol/riot_static/9.24.1/data/en_US/champion.json?v9.24.2').json()
print(r.keys())
Or you lovely target:
import pandas as pd
df = pd.read_json(
'https://static.u.gg/assets/lol/riot_static/9.24.1/data/en_US/champion.json?v9.24.2')
print(df)
Output:
type ... data
Aatrox champion ... {'version': '9.24.1', 'id': 'Aatrox', 'key': '...
Ahri champion ... {'version': '9.24.1', 'id': 'Ahri', 'key': '10...
Akali champion ... {'version': '9.24.1', 'id': 'Akali', 'key': '8...
Alistar champion ... {'version': '9.24.1', 'id': 'Alistar', 'key': ...
Amumu champion ... {'version': '9.24.1', 'id': 'Amumu', 'key': '3...
... ... ... ...
Zed champion ... {'version': '9.24.1', 'id': 'Zed', 'key': '238...
Ziggs champion ... {'version': '9.24.1', 'id': 'Ziggs', 'key': '1...
Zilean champion ... {'version': '9.24.1', 'id': 'Zilean', 'key': '...
Zoe champion ... {'version': '9.24.1', 'id': 'Zoe', 'key': '142...
Zyra champion ... {'version': '9.24.1', 'id': 'Zyra', 'key': '14...
[147 rows x 4 columns]
Upvotes: 1