Search code examples
pythonhtmlbeautifulsoupurllib

Trying to read data from War Thunder local host with python


Basically I'm using python to send serial data to an arduino so that I can make moving dials using data from the game. This would work because you can use the url "localhost:8111" to give you a list of these stats when ingame. The problem is I'm using urllib and BeautifulSoup but they seem to be blindly reading the source code not giving the data I need.

The data I need comes up when I inspect the element of that page. Other pages seem to suggest that using something to run the HTML in python would fix this but I have found no way of doing this. Any help here would be great thanks.


Solution

  • Not the poster but i have been working on this with him. We managed to get it working. In case anyone else is having this problem here is the code that got it to display our speed

    from selenium import webdriver
    import time
    driver = webdriver.Chrome()
    driver.get("http://localhost:8111")
    time.sleep(1)
    while True:
        elements = driver.find_element_by_id("stt-IAS, km/h")
        print(elements.text)
    

    Don't know why the time.sleep is needed but the code doesn't seem to work without it.