mechanize

html form submission

I'm looking at the html form of an external website (not maintained by myself) in the following format : <form onsubmit="return check(this)" method=post action=address.aspx target=ttPOST> .... </form> I wish to post data to this external website without having to go through the form and pressing submit. Can I simply go to the url 'a...

Cucumber, Webrat, Mechanize: can't access "response" variable

I am trying to use Cucumber+webrat+mechanize to test some web pages. In a simple example, I set up something like ... And I goto Home Then I should see "Welcome" And I have the following in my step file: Then /^I should see "([^\"]*)"$/ do |text| response_body.should contain(text) end I get an error, complaining that there is no...

Mechanize and NTLM Authentication

The following code generates a 401 => Net::HTTPUnauthorized error. From the log: response-header: x-powered-by => ASP.NET response-header: content-type => text/html response-header: www-authenticate => Negotiate, NTLM response-header: date => Mon, 02 Aug 2010 19:48:17 GMT response-header: server => Microsoft-IIS/6.0 response...

Why am I getting an Internal Server error while using Mechanize to do the file fetching?

I'm having trouble downloading an mp4 file using WWW::Mechanize. A normal browser, like Firefox, can do the file fetching without any problem with or without Javascript enabled. So it seems to me Javascript, the usual suspect, hasn't played a real part in my problem. I've also added in my script the same headers as sent by Firefox to the...

Forms not getting submitted with MECHANIZE in PYTHON!

from mechanize import * import cookielib from BeautifulSoup import BeautifulSoup br = Browser() br.open('http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp') br.select_form(name="main") br.find_control(name="disclaimer").selected = True reponse = br.submit() print reponse.read() The Above is my code. Now I expect it to sh...

Ruby/Mechanize Multipart Form With File Upload to a Mediawiki

I've been trying to write a ruby script using mechanize to batch upload a large number of images to a MediaWiki. The script runs without any errors but I suspect there is something wrong with the way I'm handling multipart forms with mechanize. The result variable at the end of the code gives no indication of success or failure, it just ...

ruby: irb gives NameError attempting to use mechanize gem (ubuntu)

On my ubuntu box, irb (ruby) gives a NameError when I try to use the mechanize gem: $ irb irb(main):001:0> require 'mechanize' => true irb(main):002:0> Mechanize.new NameError: uninitialized constant Mechanize from (irb):2 from :0 gem env shows this: RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2...

How to remove duplicates in Links genrated using mechnize in Python?

Here is my code in python which Genrates a list of link objects. I want to remove duplicates form them. cb = list() for link in br.links(url_regex="inquiry-results.jsp"): cb.append(link) print set(cb) But It returns the error unhashable instance. link is something like this - Link( base_url='http://casesearch.courts.state...

Error in Python Mechanize - "mechanize._mechanize.BrowserStateError: not viewing HTML"

for link in br.links(url_regex="inquiry-results.jsp"): cb[link.url] = link for page_link in cb.values(): for link in br.links(url_regex="inquiryDetail.jis"): .................... url = link.absolute_url br.follow_link(link) ...................... br.follow_link(page_link) T...

How to uniquify an array in Ruby?

I am aware of ".uniq" method but it is not working here. I pushed Mechanize link instances in an array and applied it but it is not removing duplicates. Here is the array.. #<Mechanize::Page::Link "2" "/inquiry/inquiry-results.jsp?d-16544-p=2&middleName=&firstName=&lastName=JOHN">, #<Mechanize::Page::Link "3" "/inquiry/inquiry-results.j...

Why arent fields getting detected in Ruby Mechanize?

http://casesearch.courts.state.md.us/inquiry/inquirySearchParam.jis agent = Mechanize.new form = agent.get("http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp").forms.first form.checkbox_with(:name => /disclaimer/).check page = form.submit The above code submits the discalimer in the above website. Now after submit...

Using Mechanize to submit a form for web-automation - returning an error.

for control in form.controls: if control.type == 'text': if 'user' in control.name: control.value = 'blah' if 'mail' in control.name: control.value = 'blah' if control.type == 'password': if 'pass' in control.name: control.value = 'blah'...

Python Auto Fill with Mechanize

Could someone help me or share some code to auto fill a login with mechanize (http://wwwsearch.sourceforge.net/mechanize/)? I want to make a python script to log me into my favorite sites when I run it. Thanks! ...

How do I visit consequent result pages at wigle.net using Mechanize?

I have the following code which uses the WWW::Mechanize and HTML::TableExtract modules. Everything works like a charm, except that I'm not capable of moving to the next pages. I'm trying to get a list of hotspots from http://www.wigle.net/gps/gps/main. The UserID is natty_a, the password is natty. Click on [searching], and then on Query....

how do i set a timeout value for python's mechanize?

How do i set a timeout value for python's mechanize? ...

how do i get python's mechanize to stop following meta refresh redirects?

I have a script which gets a webpage with a meta refresh. I need to parse the retrieved page but mechanize seems to follow the redirect. How do I get it to stop following it? ...

Python, mechanize, proper syntax for setting multiple headers?

I can't seem to find how to do this anywere, I am trying to set multiple headers with python's mechanize module, such as: br.addheaders = [('user-agent', ' Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3')] br.addheaders = [('accept', 'text/html,application/xhtml+xml,application/xm...

Python mechanize, following link by url and what is the nr parameter?

I'm sorry to have to ask something like this but python's mechanize documentation seems to really be lacking and I can't figure this out.. they only give one example that I can find for following a link: response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1) But I don't want to use a regex, I just want to follow a link based on...

downloading only the header of a file

I'm using mechanize for scraping a website which works nicely, however since you can't tell from a link what kind of file it is linking to e.g. http://somesite.com/images.php?get=123 is it possible to download only the header only? It doesn't have to use mechanize but is there any Rails way of doing this? ...

Downloading only the header of a file

I'm using mechanize for scraping a website which works nicely, however since you can't tell from a link what kind of file it is linking to e.g. http://somesite.com/images.php?get=123 is it possible to download the header only? I'm asking this because I'd like to decide based on the filetype if I will download it. Also it would then help...