You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
508 B

#! /usr/bin/env python
import requests
from bs4 import BeautifulSoup
headers = requests.utils.default_headers()
headers.update({"User-Agent": "Mozilla/5.0"})
data = {
'codiceStazione': 'S01700Milano+Centrale',
'lang': 'IT',
}
r = requests.post('http://viaggiatreno.it/vt_pax_internet/mobile/stazione', headers=headers, data=data)
print(r.text.encode('utf-8'))
soup = BeautifulSoup(r.text, 'html.parser')
treni = soup.find_all("div", class_="bloccorisultato")
for treno in treni:
print(treno)