Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ GEM

PLATFORMS
arm64-darwin-23
arm64-darwin-24
x86_64-linux

DEPENDENCIES
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/api/conferences_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
require 'rss'
require_relative '../../services/conference/scraper_service'

class Api::ConferencesController < ApiController
skip_before_action :authenticate_request
before_action :validate_topics, only: :create
before_action :validate_params, only: :create

def scrape
url = params[:url]
unless url.present?
render json: { error: 'URL missing' }, status: :bad_request and return
end
result = ConferenceScraper::ScraperService.scrape(url)
if result[:error]
render json: { error: result[:error] }, status: :unprocessable_entity
else
render json: result
end
end
def index
@conferences = Conference.first(limit)
rss = RSS::Maker.make('2.0') do |maker|
Expand Down
24 changes: 24 additions & 0 deletions app/services/conference/scraper_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'nokogiri'
require 'open-uri'

module ConferenceScraper
class ScraperService
def self.scrape(url)
begin
html = URI.open(url)
doc = Nokogiri::HTML(html)
# Simple extraction logic (customize selectors as needed)
title = doc.at('title')&.text || doc.at('h1')&.text
date = doc.at('[itemprop*="startDate"], .date, .event-date')&.text
location = doc.at('[itemprop*="location"], .location, .event-location')&.text
{
title: title&.strip,
date: date&.strip,
location: location&.strip
}
rescue => e
{ error: e.message }
end
end
end
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
resources :conferences, only: [:create, :index] do
collection do
get :cfp
post :scrape
end
end
get '/webhooks/sync', to: 'webhooks#sync'
Expand Down