basic scraping for Reference

pull/2375/head
Gergely Gombos 2 months ago
parent 5e973d8c0f
commit 75cce72b3f

@ -0,0 +1,11 @@
module Docs
class React
class CleanHtmlReactDevFilter < Filter
def call
@doc = at_css('article')
doc
end
end
end
end

@ -0,0 +1,13 @@
module Docs
class React
class EntriesReactDevFilter < Docs::EntriesFilter
def get_name
at_css('article h1').content
end
def get_type
return 'TODO add types'
end
end
end
end

@ -7,6 +7,19 @@ module Docs
code: 'https://github.com/facebook/react'
}
version do
self.release = '18.3.1'
# TODO add /learn
self.base_url = 'https://react.dev/reference'
html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev'
options[:attribution] = <<-HTML
&copy; 2013&ndash;present Facebook Inc.<br>
Licensed under the Creative Commons Attribution 4.0 International Public License.
HTML
end
version '17' do
self.release = '17.0.2'
self.base_url = 'https://17.reactjs.org/docs/'
@ -33,7 +46,6 @@ module Docs
HTML
end
def get_latest_version(opts)
doc = fetch_doc('https://react.dev/', opts)
doc.at_css('a[href="/versions"]').content.strip[1..-1]

Loading…
Cancel
Save