astroport/zen/tools/scraping/transiscope/tests_scrap/scrapsoup.py

19 lines
510 B
Python
Executable File

#!/usr/bin/python3
from bs4 import BeautifulSoup
import urllib.request
import csv
urlpage = 'https://transiscope.org/carte-des-alternatives/#/carte/@46.33,-1.34,6z?cat=all'
# query the website and return the html to the variable 'page'
page = urllib.request.urlopen(urlpage)
# parse the html using beautiful soup and store in variable 'soup'
soup = BeautifulSoup(page, 'html.parser')
table = soup.find(attrs={'id': 'element-info'})
results = table.find_all('li')
print('Number of results', len(results))