From 8034fd960db40c27cb7ab927fd1d90b61ad5f21d Mon Sep 17 00:00:00 2001 From: ClasherKasten Date: Mon, 24 Jul 2023 23:25:52 +0200 Subject: [PATCH] update github scraper tweak github scraper to work again after GitHub UI update which gives back JSON data --- lib/docs/scrapers/github.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/docs/scrapers/github.rb b/lib/docs/scrapers/github.rb index f6014a0a..e5b48edb 100644 --- a/lib/docs/scrapers/github.rb +++ b/lib/docs/scrapers/github.rb @@ -4,5 +4,20 @@ module Docs self.type = 'github' html_filters.push 'github/clean_html' + + def process_response?(response) + if super(response) + return true + end + JSON.parse(response.body) + true + rescue JSON::ParserError, TypeError => e + false + end + + def parse(response) + parsed = JSON.parse(response.response_body) + [parsed['payload']['blob']['richText'], parsed['title']] + end end end