Created
January 12, 2022 17:16
-
-
Save voigtjessica/4ec24ea366545cc223d09144f8d69240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import pandas as pd | |
import janitor | |
from bs4 import BeautifulSoup | |
url = 'https://www.nrw-live.de/staedte-nrw' | |
req = requests.get(url) | |
soup = BeautifulSoup(req.content, 'html5lib') | |
list_stadt_nrw = soup.findAll('a') | |
list_stadt_nrw # retornou uma lista para cara <a> | |
len(list_stadt_nrw) | |
#onde começa e onde terminam as cidades: | |
list_stadt_nrw[87].text # start in 87 = 'Aachen' | |
list_stadt_nrw[482].text # ends here = 'Zülpich' | |
stadt_nrw = [] | |
for i in range(87, 482): | |
t = list_stadt_nrw[i].text | |
stadt_nrw.append(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment