Forked from jcouyang/github-contribution-widget.rb
Last active
October 24, 2022 17:03
-
-
Save ezefranca/a0ec610f875df850f8edfdeacf14e328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "nokogiri" | |
| require "open-uri" | |
| require 'json' | |
| url = "https://speakerdeck.com/#{params['username']}?page=#{params['page']}" | |
| document = Nokogiri::HTML(open(url)) | |
| images = document.xpath('//div[@class="deck-preview-slide"]').map { |node| 'https:' + node.xpath('//@style').text.split(';')[1].split(':')[2].split('\'')[0] } | |
| #titles = document.xpath('//div[@class="deck-preview-slide"]').map { |node| node.xpath('//div[@class="deck-title px-3 pt-3 text-truncate"]') }[0].map { |title| title.text.strip } | |
| urls = document.xpath('//div[@class="row mt-4 mb-4"]')[0].xpath('//div[@class="col-12 col-md-6 col-lg-4 mb-5"]/a//@href').map { |url_path| "https://speakerdeck.com" + url_path } | |
| { | |
| :page => #{params['page']}, | |
| :images => images, | |
| :urls => urls | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment