Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML::LinkExtor Question

Status
Not open for further replies.

WebStuck

Programmer
Joined
Apr 12, 2003
Messages
79
Location
US
Hi,

I am trying to find the first img tag that contains a jpg file from a website. I got my script to contect to the website, but I need to know how to find the jpg file. HTML::LinkExtor sounds like it would work well to do this, but I am unfamiliar with that module. Any help would be greatly appreciated.

Kind Regards,
Ben Cunningham
 
search the HTML file line-by-line WHILE(<INFILE>) and search until you find an img tag /<img src=[^>]+>/

Regards
Duncan
 
I'm searching the actual website and not a file. However, I guess I could do it the same way, but the LinkExtor module seems built to do this. Also, I need to get the jpg file name from the first img tag that contains a jpg file.

Thanks,
Ben
 
I'm am personally - and probably quite incorrectly, not 'that' fond of modules. I am trying to learn Perl and find them frustrating because they work in there own strange ways. But this is just me. I prefer to try to get the job done without them so I understand how the language works.

$_ = 'this is a line of text with <img src=&quot;/folder1/folder2/image.gif&quot;> an image description in it';

/<img src=\&quot;([^\&quot;]+\/([a-zA-Z]+.gif))\&quot;>/;

print &quot;image with path is : $1\n&quot;;

print &quot; image alone is : $2\n&quot;;


Duncan
 
... don't know if Coderifous would agree with me?

Duncan
 
I'm still trying to learn how to do this with the HTML::LinkExtor module, as I may do a lot of parsing website type of scripts in the future. I think this module may eventually save me quite a bit of time once I learn how to use it better. I think I am making some progress.

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top