mechanize

Install mechanize with Ruby 2.3 on Windows 7 got error

回眸只為那壹抹淺笑 提交于 2019-12-12 04:03:59
问题 I'm trying to install Mechanize with Ruby 2.3 on Windows 7. However I got the following error. Could anyone point me to the right direction? PS C:\DevKit> ruby --version ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32] PS C:\DevKit> gem install mechanize Fetching: net-http-digest_auth-1.4.gem (100%) Successfully installed net-http-digest_auth-1.4 Fetching: net-http-persistent-2.9.4.gem (100%) Successfully installed net-http-persistent-2.9.4 Fetching: mime-types-2.99.1.gem (100%)

What does this error mean: ValueError: unknown POST form encoding type ' ' (and how to solve it?)

给你一囗甜甜゛ 提交于 2019-12-12 02:16:16
问题 I'm trying to crawl a website (http://www.dataescolabrasil.inep.gov.br/dataEscolaBrasil/home.seam) using mechanize but I am getting an error I cannot understand (and therefore cannot solve). That's probably due to my poor knowledge of web development. Here's what I'm trying to do: import mechanize # this is the website I want to crawl LINK = "http://www.dataescolabrasil.inep.gov.br/dataEscolaBrasil/home.seam" br = mechanize.Browser() br.open(LINK) request = mechanize.Request(LINK) response =

Getting the `certificate verify failed (OpenSSL::SSL::SSLError)` erro with Mechanize object

荒凉一梦 提交于 2019-12-12 01:29:30
问题 For the below code got certificate verify failed (OpenSSL::SSL::SSLError) : CODE require 'mechanize' agent = Mechanize.new #{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE} agent.set_proxy('3.209.30.25', 80) agent.ssl_version='SSLv3' agent.verify_mode= OpenSSL::SSL::VERIFY_PEER page = agent.get "https://gegsltraining.aravo.com/" Error C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net/http/persist ent/ssl_reuse.rb:70:in `connect': SSL_connect returned=1

Clicking image with mechanize

风格不统一 提交于 2019-12-12 01:29:22
问题 clicking a text agent.click(page.link_with(:text => 'some_text') with mechainze is piece of cake. How to click an image with mechanize? 回答1: It is rather similar. You just need to grab one of the attributes of your image. have a look below..: agent.click(page.image_with(:alt=> 'your image') 回答2: Clicking on a pure HTML image will typically have no effect. If the image has an onclick handler, you will not be able to click on it with Mechanize as it does not support javascript. You may want to

Get a link's “href” using mechanize

£可爱£侵袭症+ 提交于 2019-12-12 01:25:19
问题 I wanna get href value of a link with a specific class name (in this case class name contains word fbxWelcomeBoxBlock) I tried @agent = Mechanize.new page=@agent.get("https://www.facebook.com/") mylinks=page.links_with(:class => 'fbxWelcomeBoxBlock _8o _8s lfloat _ohe') puts mylinks.size # prints zero now... but it didnt work . (I am using mechanize in ruby now) 回答1: It's fully dynamic page. Mechanize does not execute JS. 来源: https://stackoverflow.com/questions/28908915/get-a-links-href-using

Using the Mechanize gem with the Nokogirl gem?

雨燕双飞 提交于 2019-12-11 19:52:34
问题 I'm trying to scrape a website that requires authentication to get an element on a page with an id of #cellTotal . Right now, using Mechanize I have logged into the page I want to access, but using basic Nokogiri functions like: @selector = page.css("#cellTotal").text Gives me this error: undefined method `css' for #<Mechanize::Page:0x61234f8> Here is what I have so far: agent = Mechanize.new agent.get("example.com") agent.page.forms[0]["username_field"] = "username" agent.page.forms[0][

Get mechanize to go through x amounts of links and get all the titles?

我的未来我决定 提交于 2019-12-11 19:03:12
问题 Basically I want to use mechanize to go through all the pages from a-z on this site http://www.tv.com/shows/sort/a_z/ then, for each letter get the title of every show on all the pages for the letter "a". At the moment I am just trying to get it to work with the letter "a". This is what I have so far but don't know where to go from here? require 'mechanize' agent=Mechanize.new goog = agent.get "http://www.tv.com/shows/sort/a_z/" search = goog.link_with(:href => "/shows/sort/a/").click 回答1:

Log in to www.virtualtrader.co.uk using python requests or similar module?

余生颓废 提交于 2019-12-11 18:49:21
问题 I'm trying to log in to the Virtual Trader website using the python requests module - I have limited experience in this area so would appreciate some help. Previously I have used the following code to log in to a similar website: import requests USERNAME = 'VALID EMAIL' PASSWORD = 'VALID PASSWORD' page = { 'index':'http://www.bullbearings.co.uk/', 'login':'http://www.bullbearings.co.uk/login.php', 'trade':'http://www.bullbearings.co.uk/stock.trade.php?epic=', 'portfolio':'http://www

Ruby, Mechanize, OAuth, and LinkedIn, all in one happy family?

我的梦境 提交于 2019-12-11 13:49:05
问题 I am building a Ruby on Rails app that: a) authenticates the user through OAuth via LinkedIn, and I would like to: b) use the acquired OAuth token to authenticate Mechanize for access to http://www.linkedin.com (instead of re-entering the user-name/password into the Mechanize agent). So, a) is it possible to authenticate Mechanize http access via an OAuth token, b) will this work with LinkedIn, and c) can anyone point me to a Ruby example? Here are my gems: gem 'omniauth', '~> 1.3', '>= 1.3.1

Data scraping multiple array creation and ordering

橙三吉。 提交于 2019-12-11 12:57:53
问题 We're trying to scrape the course names, qualification and duration of the course and store each in a separate array. With the below we pull all of that, but it seems to be in random order, with some parts potentially ordered by page etc. Wondering if anybody is able to help. require 'mechanize' mechanize = Mechanize.new @duration_array = [] @qual_array = [] @courses_array = [] page = mechanize.get('http://search.ucas.com/search/results?Vac=2&AvailableIn=2016&IsFeatherProcessed=True&page=1