mechanize
- Examples
Los navegadores clonados se utilizan para las descargas multihilo, ya que mechanize no es seguro. | Cloned browsers are used for multi-threaded downloads, since mechanize is not thread safe. |
De manera predeterminada devuelve un navegador mechanize que soporta cookies, ignora robots.txt, tiene en cuenta los refrescos y tiene un agente de usuario de tipo mozilla firefox. | By default it returns a mechanize browser instance that supports cookies, ignores robots.txt, handles refreshes and has a mozilla firefox user agent. |
Esta vez utilizaremos Mechanize para interactuar con un site de forma que podamos extraer esos datos. | This time we'll use Mechanize to interact with a site so that we can extract the data from it. |
Ahora que tenemos una idea de cómo utilizar Mechanize podemos utilizar todo lo aprendido en una aplicación Rails. | Now that we have an idea how to use Mechanize we can use what we've learned in a Rails application. |
Hay algunos enlaces en la página y necesitamos averiguar cómo recuperar el enlace adecuado para que Mechanize haga clic en él. | There are several links on the page and we need to work out how to get the right link for Mechanize to click on. |
Mechanize utiliza Nokogiri y añade cierta funcionalidad extra para interactuar con los sites de forma que se puede usar para tareas como hacer clic en enlaces o enviar formularios. | Mechanize uses Nokogiri and adds some extra functionality for interacting with sites so that it can used to perform tasks like clicking links or submitting forms. |
Hemos alcanzado nuestro objetivo utilizando Mechanize y Nokogiri para navegar por varias pagínas de un site, interactuando con ellas para rellenar formularios y hacer clic en enlaces y extrayendo la información que buscábamos. | So we've reached our goal. We have used Mechanize and Nokogiri to navigate through several pages on a website, interacting with it to fill in forms and click hyperlinks and extracting the information we wanted. |
Por ejemplo, para acceder a los formularios de la página podríamos invocar agent.page.forms que nos devolverá un array de objetos Mechanize::Form y dado que solo hay un formulario en nuestra página podremos ejecutar agent.page.forms.first para obtener una referencia. | For example, to get at the forms on the page we could call agent.page.forms which will return an array of Mechanize::Form objects. As there is only one form on our page we can call agent.page.forms.first to get a reference to it. |
Aquí es donde entra Mechanize. | This is where Mechanize comes in. |
Esto nos devuelve un objeto de tipo Mechanize::Page que incluye todos los atributos de la página incluyendo, en nuestro caso, el formulario de login. | This returns a Mechanize::Page object which includes all of the attributes for that page including, for our page, the login form. |
Random Word
Roll the dice and learn a new word now!
Want to Learn Spanish?
Spanish learning for everyone. For free.