Helpme with this url

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dumbo
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2004 6:14 pm
Location: Argentina

Helpme with this url

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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
dumbo
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2004 6:14 pm
Location: Argentina

Post by dumbo »

dosn't work i get a blank page, i don't now what i can do now!

Please helpme.
dumbo
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2004 6:14 pm
Location: Argentina

don't work

Post by dumbo »

dosn't work i get a blank page, i don't now what i can do now!

Please helpme.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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
dumbo
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2004 6:14 pm
Location: Argentina

Please visit my site

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Please visit my site

Post 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).
dumbo
Forum Newbie
Posts: 6
Joined: Tue Feb 03, 2004 6:14 pm
Location: Argentina

this is my code

Post 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);


?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

maybe because $first_table is an array... try $first_table[]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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).
Post Reply