Sha256: 6374109a7bc6a26897175d5850d566fb28df345ea794115187257db17c529831

Contents?: true

Size: 805 Bytes

Versions: 4

Compression:

Stored size: 805 Bytes

Contents

require 'faraday'

module Pwb
  class Import::ScrapperController < ApplicationApiController
    def from_webpage
      # just a proof of concept at this stage
      unless params[:url].present?
        return render json: { error: "Please provide url."}, status: 422
      end

      target_url = params[:url]

      retrieved_properties = Pwb::SiteScrapper.new(target_url).retrieve_from_webpage

      render json: retrieved_properties
    end

    def from_api
      unless params[:url].present?
        return render json: { error: "Please provide url."}, status: 422
      end
      target_url = params[:url]
      # "https://propertywebbuilder.herokuapp.com"

      retrieved_properties = Pwb::SiteScrapper.new(target_url).retrieve_from_api

      render json: retrieved_properties
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pwb-1.4.0 app/controllers/pwb/import/scrapper_controller.rb
pwb-1.3.0 app/controllers/pwb/import/scrapper_controller.rb
pwb-1.2.0 app/controllers/pwb/import/scrapper_controller.rb
pwb-1.1.1 app/controllers/pwb/import/scrapper_controller.rb