Need help to understand how to use regex to get pruductID and image url from string.
I manage to get it one by one, but i want to have one regex for it so it come in order in the array
when i use preg_match......
<div class="thumbnailbox">
<a href="getboxnow.php?pruductid=panther" target="_top">
<img src="http://www.site.com/tmbImage.jpg" alt="panther" title="panther" border="0" height="75" width="100"></a>
</div>
So you want 'panter' in this example?
It can be a bear.
What I almost always do is get ALL the href's on the page, then filter out the one I want.
href="getboxnow.php?pruductid=panther"
So, in perl...
while($content_of_page =~ /href="(.*?)"/sig) {
$thisLink = $1;
print "$thisLink\n";
}
That should print every href tag on the page.
Next, I would probably eliminate those that do not contain "productid="
while($content_of_page =~ /href="(.*?)"/sig) {
$thisLink = $1;
unless($thisLink =~ /productid=/) { next; }
print "$thisLink\n";
}
See where I'm going?
This is my main, most used, most reliable method.
If I am feeling bold, I might put getboxnow.php? in the first while loop:
while($content_of_page =~ /href="getboxnow.php?(.*?)"/sig) {
$thisLink = $1;
print "$thisLink\n";
}
or something like that. Untested, have a ball.
Bompa
PS: On each new CMS, I grab the source code and practice offline
which saves a lot of time.