Page 1 of 1

scraping and preg_matching

Posted: Tue Jun 16, 2009 10:03 am
by avukadomusic
here is my code with problems:

$url = 'somesite/somepage';

$str = file_get_contents($url);

preg_match('/[0-9]\w(\d*). ?\$/',$str,$matches);

print_r($matches[0]);

the goal is to type in any webpage and get its source code into
$str and then find the first appearance of the symbol $ in the string
and return only the number closest to that symbol after it

1.is there something like screenscrape that not gives me the pictures and layout , just the source code so I can put it in a string like text ?

2.when I replace the "$str = file ..." with
"$str = 'hgfghfgh 7656575 ghfghf 160 $ 600 hfgcgh 340 $ 134 gffg$'"
I get "160 $" but I want only the nomber after the first $ returned and thats it. how should the preg_match be written? ( for example from this string I wanted '600' without $)