I want to track my package sent via the local post service: http://tandt.posta.sk/en.
With the tracking information, for example, RF166699170SK, I can locate the package.
but when I want to read it via PHP for example curl_setopt, via file_get_contents, or another method, I read only HTML code but in output missing text for example "Item posted at post office Dlhé Pole" which I can see on page.
because this page use iframe with some private method http://www.posta.sk/en/sps-embed#tnt?q=RF166699170SK
but when I try to read this page (iframe), output missing information about package for example "Item posted at post office Dlhé Pole".
Output:
<!DOCTYPE html>
<html class="embed">
<head>
<link href="/sps/style.css?1450227250" media="screen,print" rel="stylesheet" type="text/css" />
<link href="/sps/print.css?1445466449" media="print" rel="stylesheet" type="text/css" />
<title>Slovenská pošta</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="google" value="notranslate">
<script type="text/javascript">CONFIG={"api":"http://api.posta.sk/private","tntShare":{"en":"http://tandt.posta.sk/en/items/{number}","sk":"http://tandt.posta.sk/zasielky/{number}"},"lang":"sk","home":"http://www.posta.sk","embed":true}</script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script src="/sps/script.js?1457665771" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script><script type="text/javascript">
//<![CDATA[
try {
var pageTracker = _gat._getTracker("UA-9600731-1");
pageTracker._setDomainName("posta.sk");
pageTracker._initData();
pageTracker._trackPageview();
} catch(err) {}
//]]>
</script>
</body>
</html>
Is it possible to read about this parcel via PHP or JavaScript?
If you inspect network connection of the page you linked you can see that there some data is loaded via JSON request. In your example data is requested from http://api.posta.sk/private/search?q=RF166699170SK&m=tnt
Maybe it would be the easiest way to get data direct from this API instead of trying to parse the result. The key is the same. You can convert the response in php like this:
<?php
$packageKey = 'RF166699170SK';
$data = json_decode('http://api.posta.sk/private/search?q='.$packageKey.'&m=tnt', TRUE);
?>
But I don't know if it's allowed by your postal service. You should ask if it's prohibited to do that.
There is an open API available for package tracking. Here you will find more information and documentation: https://www.posta.sk/informacie/api-dokumentacia
Example query: http://api.posta.sk/tracking?l=en&p=1&q=RF166699170SK