How do apps like Öffi and DB Navigator access data from transportation companies if they do not provide an API?

Apps like Öffi and DB Navigator access data from transportation companies by scraping their websites for information. They simulate a user interacting with the website, retrieve the relevant data, and then parse it for display in the app. This method allows them to access the data even if the transportation companies do not provide an API.

// Example PHP code for scraping data from a website
$url = 'https://example.com/transportation-company';
$html = file_get_contents($url);

// Use a library like DOMDocument or SimpleHTMLDom to parse the HTML
$dom = new DOMDocument();
$dom->loadHTML($html);

// Find and extract the relevant data from the HTML
$elements = $dom->getElementsByTagName('div');
foreach ($elements as $element) {
    // Process and display the data as needed
    echo $element->nodeValue . "<br>";
}