LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-22-2010, 09:07 PM   #1
hawk__0
Member
 
Registered: Nov 2008
Posts: 105

Rep: Reputation: 15
WWW::Mechanize:Image, how do I get the image URL?


I've written a script/program but when want it to get the <img src="abc.jpg"> form my input. Essentially I have something like this:
EDIT: This is the chunk of code I'm trying to get extracting images, but this is broken. I can't figure it out!
Code:
foreach my $link ($mech->links) 
{
  if ($link->url =~ /html/)
  {
    if ($filter)
    {
      if ($link->text =~ /$keywords/i)
      {
	  print FILE '<a href=' . "$preurl" . $link->url, '>', $link->text, '</a><br \>';
      }
    }
    else
    {
    print FILE '<a href=' . "$preurl" . $link->url, '>', $link->text, '</a><br \>';
    my $imglink = $preurl . $link->url . "\n";
    print "$imglink";
    
########################
    my $imageref = $mech->find_image( url_regex => qr/'$imglink'/ );
    my $ref_type = undef;
    my $img_link = undef;
    if ($mech->success){
      $img_link=$imageref->url();
      $ref_type=ref $imageref;
    }
    else
    {
    print "No image found\n";
    }

how can I properly extract the image name/tags from this?

I'm using perl

Last edited by hawk__0; 03-22-2010 at 09:50 PM.
 
Old 03-23-2010, 01:43 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Please elaborate what actually is expected from the script
Code:
my $imageref = $mech->find_image( url_regex => qr/'$imglink'/ );
Are these single quote intentional in this regex ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I add image to URL watcher69b Programming 2 01-28-2009 05:21 AM
"www::mechanize"-->www.cpan.org using this module login to secure website vvnkishore Linux - General 0 10-04-2007 01:14 AM
Using WWW::Mechanize in perl nigel_mark2004 Programming 3 04-06-2006 07:00 PM
Small image beside URL in browser ctkroeker Linux - General 3 12-16-2005 05:01 PM
WWW::Mechanize dexter_modem Programming 0 06-23-2003 04:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration