Commit efbcda33 authored by Bc. Peter Štieber's avatar Bc. Peter Štieber
Browse files

Update index.php

parent b1e70e7a
Pipeline #12524 passed with stage
in 1 minute and 8 seconds
<?php
/**
* Created by PhpStorm.
* User: uppermost
......@@ -7,27 +6,181 @@
* Time: 19:29
*/
//$ch = curl_init('https://aplikacie.zsr.sk/infotabule/StationDetail.aspx?id=136002&t=2');
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//$content = curl_exec($ch);
//
//if (curl_errno($ch)) {
// echo 'error:' . curl_error($ch);
//} else {
// $doc = new DOMDocument();
// $doc->loadHTML($content);
// $sxml = simplexml_import_dom($doc);
//
// echo '<pre>';
// print_r($sxml);
// echo '<pre>';
//
//
//
//}
//curl_close($ch);
echo 'ez';
$useragent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36';
$timeout = 99999;
$dir = dirname(__FILE__);
$cookie_file = $dir . '/cookies/' . md5($_SERVER['REMOTE_ADDR']) . '.txt';
$ch = curl_init('https://aplikacie.zsr.sk/infotabule/StationDetail.aspx?id=136002&t=2');
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$content = curl_exec($ch);
if (curl_errno($ch)) {
echo 'error:' . curl_error($ch);
} else {
$doc = new DOMDocument();
$doc->loadHTML($content);
$sxml = simplexml_import_dom($doc);
$first_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[2]->td as $item) {
array_push($first_row, $item);
}
$second_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[3]->td as $item) {
array_push($second_row, $item);
}
$third_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[4]->td as $item) {
array_push($third_row, $item);
}
$fourth_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[5]->td as $item) {
array_push($fourth_row, $item);
}
$fifth_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[6]->td as $item) {
array_push($fifth_row, $item);
}
$sixth_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[7]->td as $item) {
array_push($sixth_row, $item);
}
$seventh_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[8]->td as $item) {
array_push($seventh_row, $item);
}
$eighth_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[9]->td as $item) {
array_push($eighth_row, $item);
}
$nineth_row = array();
foreach ($sxml->body->form->div[2]->div[1]->div[0]->div[0]->div[1]->div[1]->div->div->table->tr[10]->td as $item) {
array_push($nineth_row, $item);
}
}
curl_close($ch);
?>
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
</head>
<body>
<table class="responsive-table">
<thead>
<tr>
<th>Departure</th>
<th>Category</th>
<th>Number</th>
<th>Operator</th>
<th>Destination</th>
<th>Direction</th>
<th>Platform</th>
<th>Track</th>
<th>Delay</th>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach ($first_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($second_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($third_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($fourth_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($fifth_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($sixth_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($seventh_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($eighth_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
<tr>
<?php
foreach ($nineth_row as $item) {
echo '<td>' . $item . '</td>';
}
?>
</tr>
</tbody>
</table>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment