Questions tagged [mechanize-ruby]

The Ruby library for automating interaction with websites.

The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.

193 questions
0
votes
1 answer

Login automatically to get a scraped file on Rails app with Mechanize

To login then to download a PDF file, I have a code that works perfectly fine on ruby when I Debug. Problem is, when I try to use this code on a Rails app with an instance variable, I can't download the file, guess that it's a cookie issue but I…
0
votes
1 answer

click on a link (already find by css) in ruby

I want to find a link on a local page and then click on it. Right now I am successful in finding a particular link (because there are many links with the same class), but I am unable to click on it. Here is my code: # encoding: utf-8 require…
Ahsan aslam
  • 1,149
  • 2
  • 16
  • 35
0
votes
1 answer

Use of URI method in mechanize#link

I am trying to get an URL from an available a tag. So If my html contains some text If I do something like this @url = link.search("a[@href]") It returns me the above html. If I do…
Arihant Godha
  • 2,339
  • 2
  • 26
  • 50
0
votes
1 answer

make a put with mechanize in ruby and rails server

I try make a put in a rails server I get this error: 'send_request_with_body': undefined method 'bytesize' for # (NoMethodError) this is the ruby code: agent = Mechanize.new agent.basic_auth('user@gmail.com', '12345678') a =…
user2994005
  • 57
  • 1
  • 9
0
votes
3 answers

Not able to send query parameters Mechanize Ruby

I am trying to send these parameters as string abc =…
chirag7jain
  • 1,485
  • 3
  • 26
  • 43
0
votes
1 answer

mechanize and Ruby multipart/form-data - content transfer encoding

I am trying to dispatch a multipart/form-data POST request to a remote server using mechanize 2.7.3 to automate some interactions with a remote server. Unfortunally there is no usable
, so I have to issue the POST directly. Luckily, mechanize…
Manny
  • 783
  • 1
  • 9
  • 29
0
votes
2 answers

Mechanize gem string to decimal over 1000 issue

I'm trying to use mechanize to pull some prices and I'm to the point where I can handle anything priced under $1,000 but as soon as anything hits above $1,000, the result is that I lose any integers after the thousands integer. For instance,…
dstep
  • 135
  • 3
  • 15
0
votes
1 answer

delay mchanize getting response from a web site

I am using Mechanize to get different elements from a web page, but there are some web sites that use a DDOS protector called "cloudflare" that delays the response of the website 5 seconds. I need to know if there is a method wich can delay the time…
Safouen
  • 121
  • 2
  • 10
0
votes
1 answer

Getting a specified number results when parsing with mechanize

I am parsing CNN.com to get the top five news storeis with their first paragraph. I have the following code. url = "http://edition.cnn.com/?refresh=1" agent = Mechanize.new page =…
Wasswa Samuel
  • 2,139
  • 3
  • 30
  • 54
0
votes
0 answers

Getting, visiting and limiting the number of links using Nokogiri and Mechanize?

I am trying to scrape the five latest stories from CNN.com and retrieve their links along with the first paragraph of each story. I have this simple script: url = "http://edition.cnn.com/?refresh=1" agent =…
Wasswa Samuel
  • 2,139
  • 3
  • 30
  • 54
0
votes
2 answers

Filling out calendar with Mechanize?

I want to fill out the calendar date field for www.vegas.com/lasvegastraveldeals. So far I can't seem to get the value method to work. Here is my code: require 'mechanize' agent = Mechanize.new page =…
Seal
  • 1,060
  • 1
  • 12
  • 31
0
votes
1 answer

post form parameters difference between Firefox and Ruby Mechanize

I am trying to figure out if mechanize sends correct post query. I want to log in to a forum (please see html source, mechanize log in my other question) but I get only the login page again. When looking into it I can see that firefox sends out…
Radek
  • 13,813
  • 52
  • 161
  • 255
0
votes
1 answer

Logging into a specific web page with Mechanize?

The HTML returned keeps telling me to restart the browser, and I'm a little lost: require 'rubygems' require 'mechanize' def getHtml(the_url) agent = Mechanize.new agent.keep_alive = false agent.user_agent = "gibsonSim" …
c0d3junk13
  • 1,162
  • 9
  • 6
0
votes
1 answer

In Mechanize how do I determine response type for a post_connect_hook

I am following Jimm Stout's suggestion for websites that don't set content-type. agent = Mechanize.new do |a| a.post_connect_hooks << ->(_,_,response,_) do if response.content_type.empty? response.content_type = 'text/html' …
zhon
  • 1,610
  • 1
  • 22
  • 31
0
votes
1 answer

Mechanize links_with is not filtering the text properly

I am trying to click a list of links with Mechanize gem, but apparently Mechanize's links_with(criteria) is not properly filtering based on the criteria. For debugging purposes, I am only printing out the link. The following script is printing out…
sergio.s
  • 103
  • 11