Page 1 of 1

Helpme with this url

Posted: Tue Feb 03, 2004 6:14 pm
by dumbo
I want to extract the tables in this url:

http://www.mercadodeliniers.com.ar/dll/ ... R&CP=57201

but i can't.
Need to extract the data in an array to parse it with webcell (http://www.ravis.org/)


Thanks.

Posted: Tue Feb 03, 2004 7:34 pm
by Weirdan

Code: Select all

$q=implode("",file("http://www.mercadodeliniers.com.ar/dll/agricultura1.dll/agrimerc000008?ID=&CP=65421&USUARIO=SIN%20IDENTIFICAR&LISTADO=NO"));
preg_match_all("|<TR VAlign="Bottom" BgColor="#E8EABD">.*</TR>|",$q,$matches);
foreach($matches[0] as $match){
   $match=preg_replace("|</?TR[^>]*>|","",$match);
   preg_match_all("|<TD[^>]*><span[^>]*>(.*)</span></TD>|U",$match,$field_matches,PREG_PATTERN_ORDER);
   $first_table[]=$field_matches[1];
}
print_r($first_table);
Play with it a bit

Posted: Tue Feb 03, 2004 8:04 pm
by dumbo
dosn't work i get a blank page, i don't now what i can do now!

Please helpme.

don't work

Posted: Tue Feb 03, 2004 8:08 pm
by dumbo
dosn't work i get a blank page, i don't now what i can do now!

Please helpme.

Posted: Tue Feb 03, 2004 8:14 pm
by Weirdan
It works pretty well for me, giving something like:

Code: Select all

Array
(
    &#1111;0] => Array
        (
        )

    &#1111;1] => Array
        (
            &#1111;0] => <BR>NOVILLOS Mest.EyB 401/420
            &#1111;1] => 1,980
            &#1111;2] => 2,082
            &#1111;3] => 2,032
            &#1111;4] => 2,030
            &#1111;5] => 170
            &#1111;6] => 1,970
            &#1111;7] => 2,040
            &#1111;8] => sost.
            &#1111;9] => 0,03
            &#1111;10] => <img src="/agricultura/suba.gif" width="6" height="8">
        )

    &#1111;2] => Array
        (
            &#1111;0] => NOVILLOS Mest.EyB 421/440
            &#1111;1] => 1,965
            &#1111;2] => 2,048
            &#1111;3] => 2,011
            &#1111;4] => 2,005
            &#1111;5] => 307
            &#1111;6] => 1,960
            &#1111;7] => 2,030
            &#1111;8] => sost.
            &#1111;9] => 0,03
            &#1111;10] => <img src="/agricultura/suba.gif" width="6" height="8">
        )
........................................................
    &#1111;22] => Array
        (
            &#1111;0] => TOROS Regulares
            &#1111;1] => 1,150
            &#1111;2] => 1,508
            &#1111;3] => 1,426
            &#1111;4] => 1,450
            &#1111;5] => 153
            &#1111;6] => 1,080
            &#1111;7] => 1,530
            &#1111;8] => encal.
            &#1111;9] => =
            &#1111;10] =>
        )

)
try it from the command line

Please visit my site

Posted: Tue Feb 03, 2004 8:19 pm
by dumbo
http://www.bassoenlared.com.ar/test/connect.php i dont now what you do, but i can't.

how in command line, can i with putty by ssh?
I have a paid server

thanks

Re: Please visit my site

Posted: Tue Feb 03, 2004 8:27 pm
by Weirdan
dumbo wrote:how in command line, can i with putty by ssh?
ssh to your server, cd to directory where the script is located and then type:
php connect.php

it should run the script from command line (on your server, of course).

this is my code

Posted: Thu Feb 05, 2004 3:30 pm
by dumbo
i receive only a few data. if you want try
http://www.bassoenlared.com.ar/test/connect.php it show $q
and an error
Notice: Undefined variable: first_table in /www/docs/bassoenlared.com.ar/public_html/test/connect.php on line 12 (where print_r....)

<?
error_reporting (E_ALL);
$q=implode("",file("http://www.mercadodeliniers.com.ar/dll/ ... LISTADO=NO"));
echo $q;
preg_match_all("|<TR VAlign=\"Bottom\" BgColor=\"#E8EABD\">.*</TR>|",$q,$matches);
foreach($matches[0] as $match){
$match=preg_replace("|</?TR[^>]*>|","",$match);
preg_match_all("|<TD[^>]*><span[^>]*>(.*)</span></TD>|U",$match,$field_matches,PREG_PATTERN_ORDER);
$first_table[]=$field_matches[1];
}

print_r($first_table);


?>

Posted: Thu Feb 05, 2004 4:58 pm
by Illusionist
maybe because $first_table is an array... try $first_table[]

Posted: Thu Feb 05, 2004 5:17 pm
by Weirdan
what does this return:

Code: Select all

<?php 
error_reporting (E_ALL); 
$q=implode("",file("http://www.google.com/")); 
echo $q;
?>
If this returns nothing then obviously you can't use url in file functions.
Otherwise try the following:

Code: Select all

<?php 
error_reporting (E_ALL); 
$q=implode("",file("http://www.mercadodeliniers.com.ar/dll/agricultura1.dll/agrimerc000008?ID=&CP=65421&USUARIO=SIN%20IDENTIFICAR&LISTADO=NO")); 
echo $q; 
?>
If this doesn't work - then something is wrong with the url (although it works for me).