mechanize

Ruby Mechanize https error

◇◆丶佛笑我妖孽 提交于 2019-11-30 08:46:56
I'm trying to do the following: page = Mechanize.new.get "https://sis-app.sph.harvard.edu:9030/prod/bwckschd.p_disp_dyn_sched" But I only get this exception: OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: sslv3 alert illegal parameter from /Users/amosng/.rvm/gems/ruby-1.9.3-p194/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:70:in `connect' from /Users/amosng/.rvm/gems/ruby-1.9.3-p194/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:70:in `block in connect' from /Users/amosng/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1

How to set custom user-agent for Mechanize in Rails

放肆的年华 提交于 2019-11-30 08:10:32
I know you have a set of pre-defined aliases you can use by setting agent.user_agent_alias = 'Linux Mozilla' for instance, but what if I want to set my own user agent, as I'm writing a web crawler and want to identify it, for the sites I'm indexing's sake. Just like Googlebot. There seems to be a user_agent method, but I can't seem to find any documentation about it's function. You can set the user agent from an alias a = Mechanize.new a.user_agent_alias = 'Mac Safari' Available aliases are stored in the AGENT_ALIASES constant. p Mechanize::AGENT_ALIASES Otherwise, use #user_agent to set your

I get an error in python3 when importing mechanize

喜你入骨 提交于 2019-11-30 08:00:51
问题 I get an error in python3 when importing mechanize. I've just installed mechanize into my virtualenv where python3 is installed. $ which python3 /Users/myname/.virtualenvs/python3/bin/python3 $ pip freeze mechanize==0.2.5 But, when I try to import mechanize in my python code, I get this error. import mechanize --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-6b82e40e2c8e> in <module>() ----> 1 import

Mechanize for Python 3.x

扶醉桌前 提交于 2019-11-30 07:07:10
is there any way how to use Mechanize with Python 3.x? Or is there any substitute which works in Python 3.x? I've been searching for hours, but I didn't find anything :( I'm looking for way how to login to the site with Python, but the site uses javascript. Thanks in advance, Adam. lxml.html provides form handling facilities and supports Python 3. I'm working on a similar project, but the faq for mechanize explicitly says they don't intend on supporting 3x any time soon. Is there a reason the code has to be written in 3? The way I'm trying to tackle the problem is by emulating the java script

Selenium Webdriver vs Mechanize

佐手、 提交于 2019-11-30 04:57:25
I am interested in automating repetitive data entry in some forms for a website I frequent. So far the tools I've looked up that would provide support for this in a headless fashion could be Selenium WebDriver and Mechanize. My question is, is there a fundamental technical difference in using once versus the other? Selenium is mostly used for testing. I've also noticed some folks use it for doing exactly what I'm looking for, and that's automating data entry. Testing becomes a second benefit in that case. Is there reasons to not use Selenium for what I want to do over Mechanize? Does it not

How to add cookie to existing cookielib CookieJar instance in Python?

∥☆過路亽.° 提交于 2019-11-30 03:59:46
I have a CookieJar that's being used with mechanize that I want to add a cookie to. How can I go about doing this? make_cookie() and set_cookie() weren't clear enough for me. br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) Paul Managed to figure this out import mechanize import cookielib br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) ck = cookielib.Cookie(version=0, name='Name', value='1', port=None, port_specified=False, domain='www.example.com', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure

WebBrowsing in C# - Libraries, Tools etc. - Anything like Mechanize in Perl? [closed]

一笑奈何 提交于 2019-11-29 22:30:41
Looking for something similar to Mechanize for .NET... If you don't know what Mechanize is.. http://search.cpan.org/dist/WWW-Mechanize/ I will maintain a list of suggestions here. Anything for browsing/posting/screen scraping (Other than WebRequest and WebBrowser Control). Parsing HTMLAgilityPack - http://www.codeplex.com/htmlagilitypack Web App Testing WatiN - Web Application Testing Framework (.NET) - http://watin.sourceforge.net/ Selenium - http://seleniumhq.org/ Art of Test Design Canvas - Costs Money Tools Firebug for Firefox Internet Explorer Developer Toolbar for IE Chrome has one too

Mechanize and BeautifulSoup for PHP? [closed]

隐身守侯 提交于 2019-11-29 22:25:43
I was wondering if there was anything similar like Mechanize or BeautifulSoup for PHP? Jon SimpleTest provides you with similar functionality: http://www.simpletest.org/en/browser_documentation.html I don't know how powerful BeautifulSoup is, so maybe this won't be as great ; but you could try using DOMDocument::loadHTML : The function parses the HTML contained in the string source . Unlike loading XML, HTML does not have to be well-formed to load. After using this, you should be able to access the HTML document using DOM methods -- including XPath queries. 来源: https://stackoverflow.com

Using Mechanize (Python) to fill form

老子叫甜甜 提交于 2019-11-29 19:41:01
问题 I want to fill the form on this page using python mechanize and then record the response. How should I do it? When I search for forms on this page using the following code, it shows the form only for the search. How should I locate the form name of the other form with fields such as name, gender etc? http://aapmaharashtra.org/join-us Code: import mechanize br=mechanize.Browser() br.open("http://aapmaharashtra.org/join-us") for form in br.forms(): print "Form name:", form.name print form 回答1:

Save image with Mechanize and Nokogiri?

戏子无情 提交于 2019-11-29 19:34:10
问题 I'm using Mechanize and Nokogiri to gather some data. I need to save a picture that's randomly generated at each request. In my attempt I'm forced to download all pictures, but the only one I really want is the image located within div#specific . In addition, is it possible to generate Base64 data from it, without saving it, or reloading its source? require 'rubygems' require 'mechanize' require 'nokogiri' a = Mechanize.new { |agent| agent.keep_alive = true agent.max_history = 0 } urls =