Search code examples
pythonbeautifulsoupwebdriver

Get data from measuring website only with BeautifulSoup


I'm trying to get data from this website https://www.dsl.cz/test-mereni-rychlosti. (This website measure speed of internet).

What I need to print:

Test rychlosti připojení: 40
Test stahování připojení: 20
Poskytovatel internetu: Vodafone

What i get:

Test rychlosti připojení: <span id="download-result">...</span>
Test stahování připojení: <span id="upload-result">...</span>
Poskytovatel internetu: None

My code:

import requests
import time
from bs4 import BeautifulSoup

URL = 'https://www.dsl.cz/test-mereni-rychlosti'
page = requests.get(URL)
soup = BeautifulSoup(page.content, 'html.parser')
time.sleep(1)

vysledek = soup.find_all('div', attrs={'class':'results'})
for job_data in vysledek:

    #Výsledek stahování
    stahovani = job_data.find('span', attrs={"id":"download-result"})
    print("Test rychlosti připojení: " + str(stahovani))

    #Výsledek ukládání
    ukladani = job_data.find('span', attrs={"id":"upload-result"})
    print("Test stahování připojení: " + str(ukladani))

    #Poskytovatel
    poskytovatatel = job_data.find('id', attrs={"id":"provider-result"})
    print("Poskytovatel internetu: " + str(poskytovatatel))

What is wrong with my code? I have a problem with this web, because there is something calculate speed of internet and I dont know, if this need use only webdriver instead BeautifulSoup (which I really need).


Solution

  • I am not so sure that that is possible with beautiful soup and requests. I tried something similar with google translate and it did not work. Try using selenium.