0

Is there an easy way to use umlauts in an URL?

import pandas as pd

#tables = pd.read_html('https://de.wikipedia.org/wiki/Liste_der_größten_Stadien_der_Welt')
tables = pd.read_html('https://de.wikipedia.org/wiki/Liste_der_gr%C3%B6%C3%9Ften_Stadien_der_Welt')

print(f'Total tables: {len(tables)}')

With umlauts in the URL I get

UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-23: ordinal not in range(128)
Red-Cloud
  • 438
  • 6
  • 13
  • `tables = pd.read_html('https://de.wikipedia.org/wiki/Liste_der_gr%C3%B6%C3%9Ften_Stadien_der_Welt')` works well for me, make sure you have up to date versions of python and pandas. If you want to encode the first URL: `tables = pd.read_html(urllib.parse.quote('https://de.wikipedia.org/wiki/Liste_der_größten_Stadien_der_Welt', safe=':+/'))` – mozway Jun 22 '23 at 07:09
  • thanks. I thought that it could be done with `read_html` and something like `encoding="...". However, your example works ... – Red-Cloud Jun 22 '23 at 07:47

0 Answers0