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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:55:05+00:00 2026-05-25T11:55:05+00:00

I have a crawl set up: require ‘anemone’ Anemone.crawl(http://www.website.co.uk, :depth_limit => 1) do |anemone|

  • 0

I have a crawl set up:

require 'anemone'

Anemone.crawl("http://www.website.co.uk", :depth_limit => 1) do |anemone|
anemone.on_every_page do |page|
  puts page.url
end
end

However I want the spider to use a Google-analytics anti-tracking tag on every URL it visits and not necessarily actually click the links.

I could use the spider once and store all of the URL’s and use WATIR to run through them adding the tag but I want to avoid this because it is slow and I like the skip_links_like and page depth functions.

How could I implement this?

  • 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-25T11:55:06+00:00Added an answer on May 25, 2026 at 11:55 am

    You want to add something to the URL before you load it, correct? You can use focus_crawl for that.

    Anemone.crawl("http://www.website.co.uk", :depth_limit => 1) do |anemone|
        anemone.focus_crawl do |page|
            page.links.map do |url|
                # url will be a URI (probably URI::HTTP) so adjust
                # url.query as needed here and then return url from
                # the block.
                url
            end
        end
        anemone.on_every_page do |page|
            puts page.url
        end
    end
    

    The focus_crawl method intended to filter the URL list:

    Specify a block which will select which links to follow on each page. The block should return an Array of URI objects.

    but you can use it as a general purpose URL filter as well.

    For example, if you wanted to add atm_source=SiteCon&atm_medium=Mycampaign to all the links then your page.links.map would look something like this:

    page.links.map do |uri|
        # Grab the query string, break it into components, throw out
        # any existing atm_source or atm_medium components. The to_s
        # does nothing if there is a query string but turns a nil into
        # an empty string to avoid some conditional logic.
        q = uri.query.to_s.split('&').reject { |x| x =~ /^atm_(source|medium)=/ }
    
        # Add the atm_source and atm_medium that you want.
        q << 'atm_source=SiteCon' << 'atm_medium=Mycampaign'
    
        # Rebuild the query string 
        uri.query = q.join('&')
    
        # And return the updated URI from the block
        uri
    end
    

    If you’re atm_source or atm_medium contain non-URL safe characters then URI-encode them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to crawl this page using Perl LWP: http://livingsocial.com/cities/86/deals/138811-hour-long-photo-session-cd-and-more I had code that
i have to crawl a website which has some secure pages,and ask for username
I have to crawl some values from a website. Should I use curl for
i have to crawl last.fm for users (university exercise). I'm new to python and
I am working on a hobby project in which I have to crawl different
I have a small webcrawler that sometimes has to crawl twitter and pull out
i have one domain link text i want to know that does google crawl
I have a secured site. Will Google (and other search engines) crawl the pages
I'm doing an iOS app that crawl my youtube subscription's videos. I have a
I have a website , php based. I am wondering if google crawls php

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.