nokogiri @ the movies

require ‘rubygems’
require ‘selenium-webdriver’
require ‘capybara’
require ‘capybara/poltergeist’
require ‘nokogiri’
require ‘open-uri’
require ‘csv’
require “yaml”

urlsubnameprefix = “popular-new-movies.html”
# urlSubName = “”
urlSubName = “”

# start recording time
start = Time.now

##################

doc = Nokogiri::HTML(open(“https://www.solarmovie.is/” + urlsubnameprefix + urlSubName) )
pix = doc.xpath(‘//img/@data-original’).collect {|node| node.text}

# puts doc
items = doc.xpath(‘//a/@title’).collect {|node| node.text}
items.delete(“Download Firefox”)
items.delete(“Download Chrome”)
items.delete(“Download Safari”)
items.delete(“Download Opera”)
items.delete(“advanced search”)
@titles = Array.new
@titlePix = Array.new

items.each_with_index do |item, index|

if index%2==1
# puts item
@titles[index] = (item)
end

end

pix.each_with_index do |item, index|
@titlePix[index] = (item)
end

i = 1
@titlePix.each_with_index do |item, index|
puts @titles[i]
puts @titlePix[index]
i = i + 2
end

fileHtml = File.new(“WhatsNewOnSolar.html”, “w+”)
fileHtml.puts “<html>”
fileHtml.puts “<head>”

fileHtml.puts “</head>”
fileHtml.puts “<body>”
fileHtml.puts ” <p>”
##########################
i = 1
@titlePix.each_with_index do |item, index|
fileHtml.puts “<p>#{@titles[i]}</p>”
fileHtml.puts “<img src=”#{@titlePix[index]}”>”
i = i + 2
end
##########################
fileHtml.puts ” </p>”
fileHtml.puts “</body>”
fileHtml.puts “</html>”
fileHtml.close()
##################
finish = Time.now
diff = finish – start
puts “timer: #{diff}”

#

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s