ruby - Execute the content of a second file in the first -
i have question, can edit code "twit" in ruby file send...
would better can done file... can not :(
from thank much! , first post, if mistake apology. read can not find twitter ruby updated :(
require 'twitter' openssl::ssl::verify_peer = openssl::ssl::verify_none client = twitter::rest::client.new |config| config.consumer_key = "xxxx" config.consumer_secret = "xxxx" config.access_token = "xxxx" config.access_token_secret = "xxxx" end file = file.open("scrapy.rb") ary = [] = 0 file.each_line |line| ary[i] = line.chomp += 1 end file.close j = 0 i.times client.update("#{ary[j]}") j += 1 sleep 10 end
my scrapy
require 'nokogiri' require 'open-uri' page = nokogiri::xml(open('xxxxxxxxxxxx')) eventos= page.xpath("//item") eventos.each |e| ubicacion = e.xpath "title" magnitud = e.xpath "emsc:magnitude" horautc = e.xpath("emsc:time").text.split(" ",2).last depth = e.xpath "emsc:depth" link = e.xpath "guid" puts [ubicacion, magnitud, horautc, depth, link].join "|" end
instead of
file = file.open("scrapy.rb")
simply require or load other file
load 'scrapy'
even better, can convert content of scrapy
in function, require file once @ top of first file, , call function need it.
Comments
Post a Comment