Initial commit

master
Notisset 2017-11-10 00:55:37 +01:00
commit f50c8e5fdc
2 changed files with 22 additions and 0 deletions

2
.gitignore vendored 100644
View File

@ -0,0 +1,2 @@
.idea

20
scraper.py 100755
View File

@ -0,0 +1,20 @@
#! /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)