Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74381

Python script - Web Scraping

$
0
0

I'm doing a script that get's some data from a URL (http://www.pmo.cz/portal/nadrze/cz/mereni_1_mes.htm). All i need is to get the data (And the date + time) from this chart: Chart

The problem is I can't get rid of plane lines in output and then somehow retrive the data... Is there a way to get rid of the lines + get the values? Am I doing it the wrong way or am I just stupid and can't find easy solution that's right under my nose? (I'm just starting with python so I'm so sorry if this is just another repeating question)

I tried the .rstrip function, tried to remove it with for loop, tried to convert it to another data types and nothing seems to work :(

I followed a tutorial (I can't remember which one) and ended up here:

import requests
from bs4 import BeautifulSoup

url = 'http://www.pmo.cz/portal/nadrze/cz/mereni_1_mes.htm'
res = requests.get(url)
html = res.content
soup = BeautifulSoup(html, 'html.parser')
text = soup.find_all(text=True)

output = ''
blacklist = [
    '[document]',
    'noscript',
    'header',
    'html',
    'meta',
    'head', 
    'input',
    'script',
]

for t in text:
    if t.parent.name not in blacklist:
        output += '{} '.format(t)

print(output)

Output:

 UPOZORNĚNÍ: Veškerá uváděná data jsou bez záruky.









  VD Vranov 


 Tok:

 Dyje


 Koruna hráze:

 353,39 [m n.m.]


 Kóta přelivu:

 350,10 [m n.m.]


 Maximální retenční hladina:

 351,45 [m n.m.]


 Hladina zásobního prostoru:

 348,45 [m n.m.]


 Hladina stálého nadržení:

 331,45 [m n.m.]


 Výškový systém:

 Balt p.v. 




 Schema:
















 Přejít na aktuální data (týden)













 Aktuální hodnoty  (25.01.2020 21:00):


 Hladina vody v nádrži [m n.m.]


 341,46 


 Objem [mil. m3]


 70,49 


 Přítok [m 3 .s -1 ]


 3,42 


 Odtok [m 3 .s -1 ]


 2,66 


 Srážky [mm]


 0,0 


 Teplota vzduchu [°C]


 -1,3 







Viewing all articles
Browse latest Browse all 74381

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>