Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
from bs4 import BeautifulSoup import requests import pandas as pd import re url="https://infopasazer.intercity.pl/?p=station&id=33605" html_content = requests.get(url) html_content.encoding = "utf-8" soup = BeautifulSoup(html_content.text, "lxml") gdp = soup.find_all("table", attrs={"class": "table table-delay mbn"}) print("Number of tables on site: ",len(gdp)) table1 = gdp[0] body = table1.find_all("tr") head = body[0] body_rows = body[1:] headings = ['Numer', 'Przewoznik', 'Data', 'Relacja', 'Przyjazd_plan', 'Opoznienie'] all_rows = [] for row_num in range(len(body_rows)): row = [] for row_item in body_rows[row_num].find_all("td"): aa = re.sub("(\xa0)|(\n)|,","",row_item.text) row.append(aa) all_rows.append(row) df = pd.DataFrame(data=all_rows,columns=headings) #print all connections from 'Warszawa Centralna' from current time print(df) #dataframe for given connection i.e. "Kraków Główny - Gdynia Główna" from 'Warszawa Centralna' con = 'Kraków Główny - Gdynia' print() print('Departure time for connection {} from Warszawa-Centralna'.format(con)) print(df[ df['Relacja'] == 'Kraków Główny - Gdynia Główna' ]) OUTOUT: Number of tables on site: 2 Numer Przewoznik Data Relacja Przyjazd_plan Opoznienie 0 93150/1 Koleje Mazowieckie 2021-11-19 Modlin - Warszawa Centralna 01:00 0 min 1 35170/1 KARPATY PKP Intercity 2021-11-19 Kraków Główny - Gdynia Główna 05:23 0 min 2 61171/0 KARKONOSZE PKP Intercity 2021-11-19 Jelenia Góra - Warszawa Wschodnia 05:45 0 min Departure time for connection Kraków Główny - Gdynia from Warszawa-Centralna Numer Przewoznik Data Relacja Przyjazd_plan Opoznienie 1 35170/1 KARPATY PKP Intercity 2021-11-19 Kraków Główny - Gdynia Główna 05:23 0 min
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)