1
0
Эх сурвалжийг харах

basic scraping for Reference

Gergely Gombos 1 жил өмнө
parent
commit
75cce72b3f

+ 11 - 0
lib/docs/filters/react/clean_html_react_dev.rb

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

+ 13 - 0
lib/docs/filters/react/entries_react_dev.rb

@@ -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

+ 13 - 1
lib/docs/scrapers/react.rb

@@ -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]