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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:46:24+00:00 2026-06-01T10:46:24+00:00

I have this code require ‘mechanize’ @agent = Mechanize.new page = @agent.get(‘http://something.com/?page=1’) next_page =

  • 0

I have this code

require 'mechanize'
@agent = Mechanize.new
page = @agent.get('http://something.com/?page=1')
next_page = page.link_with(:href=>/^?page=2/).click

As you can see this code should go to the next page.

The next_page should have url http://something.com/?page=2

How to get current url for next_page?

  • 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-01T10:46:25+00:00Added an answer on June 1, 2026 at 10:46 am
    next_page.uri.to_s 
    

    See http://www.rubydoc.info/gems/mechanize/Mechanize/Page/Link#uri-instance_method and http://ruby-doc.org/stdlib-2.4.1/libdoc/uri/rdoc/URI.html

    For testing purposes, I did the following in irb:

    require 'mechanize'
    @agent = Mechanize.new
    
    page = @agent.get('http://news.ycombinator.com/news')
    => #<Mechanize::Page
     {url #<URI::HTTP:0x00000001ad3198 URL:http://news.ycombinator.com/news>}
     {meta_refresh}
     {title "Hacker News"}
     {iframes}
     {frames}
     {links
      #<Mechanize::Page::Link "" "http://ycombinator.com">
      #<Mechanize::Page::Link "Hacker News" "news">
      #<Mechanize::Page::Link "new" "newest">
      #<Mechanize::Page::Link "comments" "newcomments">
      #<Mechanize::Page::Link "ask" "ask">
      #<Mechanize::Page::Link "jobs" "jobs">
      #<Mechanize::Page::Link "submit" "submit">
      #<Mechanize::Page::Link "login" "newslogin?whence=%6e%65%77%73">
      #<Mechanize::Page::Link "" "vote?for=3803568&dir=up&whence=%6e%65%77%73">
      #<Mechanize::Page::Link
       "Don’t Be Evil: How Google Screwed a Startup"
       "http://blog.hatchlings.com/post/20171171127/dont-be-evil-how-google-screwed-a-startup">
      #<Mechanize::Page::Link "mikeknoop" "user?id=mikeknoop">
      #<Mechanize::Page::Link "64 comments" "item?id=3803568">
      #<Mechanize::Page::Link "" "vote?for=3802515&dir=up&whence=%6e%65%77%73">
      # Omitted for brevity...
    
    next_page.uri
     => #<URI::HTTP:0x00000001fa7818 URL:http://news.ycombinator.com/news2> 
    
    next_page.uri.to_s
     => "http://news.ycombinator.com/news2" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, and I login successfully: require 'mechanize' require 'logger' agent =
I have this code: require 'facebook.php'; $facebook = new Facebook(array( 'appId' => 'xxxxxxx', 'secret'
I have this code: require 'rubygems' require 'activeresource' ActiveResource::Base.logger = Logger.new(#{File.dirname(__FILE__)}/exercises.log) class Exercise <
I have this testing code in PAGE A : <?php require_once('../mysite/php/classes/eventManager.php'); $x=new EventManager(); $y=$x->loadNumbers();
i have this code: require 'java' require 'iText-5.0.6.jar' module Pdf include_package com.itextpdf.text.pdf include_package java.io
i have this code: <!DOCTYPE HTML> <html> <head> <script src=http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js type=text/javascript djConfig=parseOnLoad: true></script> <script
I have this code in the __constructor $this->Reliability = new Reliability(name,url); Problem: I got
I have this code: require(class.XMLHttpRequest.php); function hot($news){ $url=https://localhost/search.aspx?search=.$news.; $ajax=new XMLHttpRequest(); $ajax->setRequestHeader(Cookie,Cookie: host); $ajax->open(GET,$url,true); $ajax->send(null);
I'm trying to get socket.io set up on Heroku, so I have this code
I have this code to check if the site is up or down: require

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.