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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:00:47+00:00 2026-06-02T13:00:47+00:00

I am scrapping google using following code def google_search(query) page = @agent.get(‘http://www.google.com’) google_form =

  • 0

I am scrapping google using following code

def google_search(query)
  page = @agent.get('http://www.google.com')
  google_form = page.form_with(:name => 'f')
  google_form.q = query
  page = @agent.submit(google_form)
  page
end

but sometimes i get NoMethodError: undefined methodq=’ for nil:NilClass` error. What might be the issue?

  • 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-02T13:00:49+00:00Added an answer on June 2, 2026 at 1:00 pm

    You are using the sample code from the docs, there is no form with that name in google search, try “gbqf” but it might differ depending on locale or various settings. When you are using mechanize use “pp” to pretty print the elements during development to see what you are fetching and going next.

    Working .rb sample (updated from http://mechanize.rubyforge.org/EXAMPLES_rdoc.html) to get first 10 results by query.

    require 'rubygems'
    require 'mechanize'
    
    a = Mechanize.new { |agent|
      agent.user_agent_alias = 'Mac Safari'
    }
    
    a.get('http://google.com/') do |page|
      search_result = page.form_with(:name => 'gbqf') do |search|
        search.q = 'ruby mechanize'
      end.submit
    
      search_result.search(".//a[@class='l']").each_with_index.map do |link, i|
        puts "#{i} #{link.content}"
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a small java smtp library ( http://code.google.com/p/subethasmtp/ ), by this I
I'm using this example to fetch links from a website : http://www.merchantos.com/makebeta/php/scraping-links-with-php/ $xpath =
There’s a really cool diff class hosted by Google here: http://code.google.com/p/google-diff-match-patch/ I’ve used it
After long search in repo folders I found rhino1_7R2.jar for Android at http://code.google.com/p/android-scripting/source/browse/rhino/rhino1_7R2.jar Unfortunately
Scraping pages using BeautifulSoup; trying to filter out links that end in ...html#comments Code
I've done site scraping of secure page of any site on http by below
I have successfully implemented code to plot multiple locations on google maps dynamically. Solution:
Using the scripting framework (javax.script.*), it's really easy to get basic integration between Java
I was looking for a way to retrieve Google search results, using RoR. I
In this question , I got the following answer: Looking at Google's maps script

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.