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 8793291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:06:14+00:00 2026-06-13T23:06:14+00:00

Im trying to parse some html tags using perl module Web::Scraper but seems Im

  • 0

Im trying to parse some html tags using perl module Web::Scraper but seems Im an inept using perl. I wonder if anyone can look for mistakes in my code…:

This is my HTML to parse (2 urls inside li tags):

<more html above here>
<div class="span-48 last">
<div class="span-37">
  <div id="zone-extract" class="123">
      <h2 class="genres"></h2>  
                <li><a href="**URL_TO_EXTRACT_1**">1</a></li>
                <li><a class="sel" href="**URL_TO_EXTRACT_2**">2</a></li>
        <li class="first">Pàg</li>
  </div>
</div>      
</div>
<more stuff from here>

Im trying to obtain:

ID:1 Link:URL_TO_EXTRACT_1

ID:2 Link:URL_TO_EXTRACT_2

With this perl code:

my $scraper = scraper {
    process ".zone-extract > a[href]", urls => '@href', id => 'TEXT';
    result 'urls';
};
my $links = $scraper->scrape($response);

This is one of the infinite process combinations I tried, with two different results: An empty return, or all the urls inside code (and I only need links inside zone-extract).

Resolved with mob’s contribution… #zone-extract instead .zone-extract 🙂

  • 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-06-13T23:06:15+00:00Added an answer on June 13, 2026 at 11:06 pm
    #!/usr/bin/env perl 
    use strict;
    use warnings;
    
    use Web::Scraper;
    
    my $html = q[
    <div class="span-48 last">
    <div class="span-37">
    <div id="zone-extract" class="123">
    <h2 class="genres"></h2>  
    <li><a href="**URL_TO_EXTRACT_1**">1</a></li>
    <li><a class="sel" href="**URL_TO_EXTRACT_2**">2</a></li>
    <li class="first">Pàg</li>
    </div>
    </div>      
    </div>
    ];      # / (turn off wrong syntax highlighting)
    
    my $parser = scraper {
        process '//div[@id="zone-extract"]//a', 'urls[]' => sub {
            my $url =  $_[0]->attr('href') ;
            return $url;
        };
    
    };
    
    my $ref = $parser->scrape(\$html);
    
    print "$_\n" for @{ $ref->{urls} };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse a html doc using some code I found from this
I'm trying to parse some HTML with DOM in PHP, but I'm having some
I am trying to parse some HTML using NekoHTML . The problem is that
I'm trying to parse some HTML using XPath in Java. Consider this HTML: <td
I'm trying to parse some HTML using the HTML Agility Pack. The following code
I'm trying to parse some returned html (from http://www.google.com/movies?near=37130 )to look for currently playing
I'm trying to parse some UTF-8 encoded html text that contains the left and
Trying to parse an HTML document and extract some elements (any links to text
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse some HTML. I use stringWithContentsOfURL to get the HTML. I

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.