Reviewing the site, you lack parameters through which to do POST.
The form sends several hidden parameters that you are not sending:
<input type="hidden" name="Go" value="">
<input type="hidden" name="ID" value="">
<input type="hidden" name="Type" value="">
<input type="hidden" name="OpenWindowNoMenuSystemKey" value="">
in addition to processing through JS. Reviewing the headers with the element inspector and testing with bash curl, I got to the minimum data to work are ID=<tu tracking>|
, Type=T
and Go=1
.
IMPORTANT: must be set if or if a |
(pipe) at the end of the tracking or if it does not, it does not work (see the escaped character %7C
which is a | ).
$ curl -XPOST http://s5.stephytrackingonline.com/Cargonam/MainWebsite.asp -d "ID=104454%7C&Type=T&Go=1" | grep ENTREGADO
Return:
<font face="Verdana" size="1">ENTREGADO</font>
I recommend that you add these parameters to your $fields
array:
$fields = array(
'ID' => $track . '|', // <---- se le DEBE poner un | (pipe) al final
'Go' => 1,
'Type' => 'T'
);
// Utiliza http_build_query en vez del foreach + rtrim que estás usando
$fields_string = http_build_query($fields);