Reputation: 31
require 'rubygems'
require 'nokogiri'
require 'mechanize'
agent = Mechanize.new
page = agent.get('https://www.instagram.com/accounts/login/')
forms = page.forms.first
pp form
I am trying to locate the form to login to the instagram website. I cannot seem to get mechanize to locate the form even though it should be the only one on the page. When I pretty print the page I get back blank output.
Upvotes: 0
Views: 309
Reputation: 26758
This page uses Javascript to render the form, which mechanize doesn't run. If you want to see what a page looks like without Javascript, you can open it with the lynx browser.
Selenium can be used instead. After installing a driver such as for chrome (see here), the API is pretty similar:
driver = Selenium::WebDriver.for :chrome
driver.navigate.to "https://www.instagram.com/accounts/login/"
first_form = driver.find_elements(css: "form")[0]
Upvotes: 1