I'm trying to connect to a website to do a scrape to get a daily URL from an <img> tag and am failing hopelessly. Connecting and reading is easy to do but when I do my preg_match I don't seem to be getting anywhere.
The page has many links on it and the one I want has a specific alt tag for the image.
The alt tag is: alt="free image" then the src comes afterwards and that's where the url is that I need to convert to a variable.
My problem really is just the regex to match this properly. What am I doing wrong here?
Thanks.
NATE
Got a question? Search G O O G L E first.
The page has many links on it and the one I want has a specific alt tag for the image.
The alt tag is: alt="free image" then the src comes afterwards and that's where the url is that I need to convert to a variable.
My problem really is just the regex to match this properly. What am I doing wrong here?
Code:
<?php
// $string is the fread() of the site I connect to
preg_match ('^<[0-9a-zA-Z =\"]+alt=\"free image\"[0-9a-zA-Z =\"]+>$', $string, $matches);
$first = $matches[0];
preg_match ('^http://[0-9a-zA-Z.]+$', $first, $matches2);
echo $matches2[0];
?>
Thanks.
NATE
Got a question? Search G O O G L E first.