Class: Import::ScrapperController
- Inherits:
-
ApplicationApiController
- Object
- ApplicationApiController
- Import::ScrapperController
- Defined in:
- app/controllers/pwb/import/scrapper_controller.rb
Instance Method Summary collapse
Instance Method Details
#from_api ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/pwb/import/scrapper_controller.rb', line 18 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 |
#from_webpage ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/pwb/import/scrapper_controller.rb', line 5 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 |