Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3786728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:43:44+00:00 2026-05-19T11:43:44+00:00

I’m able to grab the first image fine, but then the content seems to

  • 0

I’m able to grab the first image fine, but then the content seems to be looping inside itself. Not sure what I’m doing wrong.

#!/usr/bin/perl
use LWP::Simple;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
for(my $id=1;$id<55;$id++)
{
    my $response = $ua->get("http://www.gamereplays.org/community/index.php?act=medals&CODE=showmedal&MDSID=" . $id );
    my $content = $response->content;    
        for(my $id2=1;$id2<10;$id2++)
        {
                $content =~ /<img src="http:\/\/www\.gamereplays.org\/community\/style_medals\/(.*)$id2\.gif" alt=""\/>/;
                $url = "http://www.gamereplays.org/community/style_medals/" . $1 . $id2 . ".gif";
  print "--\n\r";
  print "ID: ".$id."\n\r";
  print "ID2: ".$id2."\n\r";
  print "URL: ".$url."\n\r";
  print "1: ".$1."\n\r";
  print "--\n\r";
  getstore($url, $1 . $id2 . ".gif");
        }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:43:45+00:00Added an answer on May 19, 2026 at 11:43 am

    As others have stated, this is really a job for an HTML::Parser. Also, you should ‘use strict;’ and remove use LWP::Simple as you’re not using the library.

    You could change your regex to the following:

    $content =~ m{http://www\.gamereplays\.org/community/style_medals/([\w\_]+)$id2\.gif}s;
    

    But you won’t get style_medals/comp_graphics_10.gif – which may be what you want. I think something like the following would work better. My apologies for the style changes but I can’t resist modifying for PBP.

    #!/usr/bin/perl                                                                 
    
    use LWP::UserAgent;
    use Carp;
    use strict;
    
    my $ua = LWP::UserAgent->new();
    
    # Fetch pages from 1 to 55.  Are we sure we won't have page 56?                 
    # Perhaps consider running until a 404 is found.                                
    for (my $id = 1; $id < 55; $id++) {
    
        # Get the page data                                                         
        my $response = $ua->get( 'http://www.gamereplays.org/community/index.php?ac\
    t=medals&CODE=showmedal&MDSID='.$id );
    
        # Check for failure and abort                                               
        if (!defined $response || !$response->is_success) {
            croak 'Request failed! '.$response->status_line();
        }
    
        my $content = $response->content();
    
        # Run this loop each time we find the url                                   
      CONTENT_LOOP:
        while ($content =~ s{<img src="(http://www\.gamereplays\.org/community/styl\
    e_medals/([^\"]+))" }{}ms) {
    
            my $url   = $1;  # The entire url, no need to recreate the domain       
            my $file  = $2;  # Just the file name portion                           
            my ($id2) = $file =~ m{ _(\d+)\.gif \Z}xms; # extract id2 for debug     
    
            next CONTENT_LOOP if !defined $id2;         # Handle SOTW.gif file(s)   
    
            # Display stats about each id found                                     
            print "--\n";
            print "ID:  $id\n";
            print "ID2: $id2\n";
            print "URL: $url\n";
            print "1:   $file\n";
            print "--\n";
    
            # You might want to consider involving the $id in the filename as       
            # you could have the same filename on multiple pages                    
            getstore( $url, $file);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.