-
-
Save anonymous/e19cd23aaaea5048a2c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
# encoding: utf-8 | |
require 'pry' | |
require 'open-uri' | |
require 'nokogiri' | |
url = "http://www.tristar.eu/pt/Electr%C3%B3nica/Boombox/Radio_Stereo_CD/CD-1568/3/5277" | |
doc = Nokogiri::HTML(open(url)) | |
ALQDETALHESPB = doc.xpath(' //*[(@id = "Gegevens")]//li').collect {|node| node.text.strip} | |
det1 = 'driver.find_element(:id, "f04_000' | |
det2 = '").send_keys(ALQDETALHESPB[' | |
det3 = '])' | |
number = ALQDETALHESPB.count.to_i | |
numbers = Array.new(number) {|i| i+1 } | |
counter = numbers | |
counter.each do |counter| | |
# puts driver.find_element(:id,"add").click | |
puts det1 + counter.to_s + det2 + counter.to_s + det3 | |
end | |
## but none of these are actualy sent to the interpreter, | |
## just printed on screen, if i manualy | |
## copy paste the lines bellow in my irb session, the data is correctly placed where i want it. | |
# driver.find_element(:id, "f04_0001").send_keys(ALQDETALHESPB[1]) | |
# driver.find_element(:id, "f04_0002").send_keys(ALQDETALHESPB[2]) | |
# driver.find_element(:id, "f04_0003").send_keys(ALQDETALHESPB[3]) | |
# driver.find_element(:id, "f04_0004").send_keys(ALQDETALHESPB[4]) | |
# driver.find_element(:id, "f04_0005").send_keys(ALQDETALHESPB[5]) | |
# driver.find_element(:id, "f04_0006").send_keys(ALQDETALHESPB[6]) | |
# driver.find_element(:id, "f04_0007").send_keys(ALQDETALHESPB[7]) | |
# => [1, 2, 3, 4, 5, 6, 7] | |
# 2.2.1 :030 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment