If you want a random unsplash url image scraper without the Unsplash API in Ruby, you can use this.
- Gem open-uri
- Gem nokogiri
- Change the keyword in the rb file to search wathever you want
- Put the rb file in initializer and call him with UnsplashScraperService.new.call
require "faker"
require_relative "../config/initializers/unsplash_scraper_service"
puts "How much Flat(s) you want ?"
loop_n = STDIN.gets.chomp
loop_n.to_i.times do
flat = Flat.new(
name: "#{Faker::Address.community} in #{Faker::Address.city}",
address: Faker::Address.full_address,
description: Faker::GreekPhilosophers.quote,
price_per_night: Faker::Number.within(range: 30..120),
number_of_guests: Faker::Number.within(range: 2..10),
picture: UnsplashScraperService.new.call
)
flat.save!
end