Can I use the bot to open the browser, manually manipulate the page, and then continue to use the bot on it?

I use Ruby, Selenium WebDriver and Nokogiri to retrieve data from web pages. After loading the proper HTML, I print the contents of a specific class.

For example,

require "selenium-webdriver" require "nokogiri" browser = Selenium::WebDriver.for :chrome browser.get "https://jsfiddle.net" doc = Nokogiri::HTML.parse(browser.page_source) doc.css('.aiButton').map(&:text).join(',') 

I found that the hardest part is loading the HTML correctly. For example, the content that I want may be hidden by some javascript or it may be on another page.

Is it possible to use Selenium to load a page, and then manually manipulate the page to display the correct HTML, and then allow the bot to complete and print the content that it should use?

+8
ruby selenium screen-scraping webdriver nokogiri
source share
2 answers

You can use Selenium to interact with a web page - fill in the form fields, click buttons, etc. You can even execute your own javascript code.

Silk Leaf Selenium

Edit:

Using pry to stop code execution so you can manually manipulate the web page.

 # Code for starting Selenium session and opening the web page ... # Use pry to stop the code execution. # Resume the program using command 'exit' in the pry context require 'pry'; binding.pry # Code to get results after you manually manipulate the web page ... 
+2
source share

You can do this quite easily. I am not familiar with ruby, but I will describe the process.

1) start the driver 2) go to page 3), then ask to enter the user (in python 2, for example: continue = raw_input ("enter something and click here to continue"))

4), then do whatever you want.

When executing this script, it will stop at the question. Then you can manually manipulate the browser, and when you're done, go to the console / cmd window and type “go” and press enter. Then it will continue when you manually left the browser.

-one
source share

All Articles