Hi all,
I have created a ruby script which scraps the video url from a
website I want to implement it in rails I tried to implement it but I
am unable to implement it it shows [[undefined method `save’ for
[]:Array]]…
Here is my controller code
class DevourController < ApplicationController
require ‘net/http’
require ‘open-uri’
def index
source =[]
array = Array.new
for path in 1…2
puts “Currently Executing Page No:----#{path}”
source = Net::HTTP.get(‘devour.com’,“/#{path}”)
html_tags=source.scan(/https?:[^“]|http?:[^']/)
#html_tags.gsub(/['”]/)
#puts html_tags
videos=[]
html_tags.each do |links|
videos << links if links.include?(“/video/”)
end
videos.uniq!
#puts videos.size
l=[]
videos.each do |y|
l << y.chomp(‘/’)
array << l
end
puts l
puts “Successfully Executed”
end
array.uniq!
#puts l
puts array
puts array.size
puts “**********************************”
#Executing The Links To Get The Video Links
@original =[]
array.each do |f|
f.each do |url|
puts url.class
puts url
uri=URI(url)
@original << Net::HTTP.get(uri)
end
end
puts @original
puts @original.size
end
def create
@original=Link.all
@original.save
end
end