No commit activity in last 3 years
No release in over 3 years
Gem to pull and parse articles from Telegra.ph.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
>= 0
~> 10.0
~> 3.0

Runtime

~> 1.6.8
 Project Readme

telegraph-parser

Gem to pull and parse articles from Telegra.ph.

Installation

Add this line to your application's Gemfile:

gem 'telegraph-parser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install telegraph-parser

Usage

Load parser to your project.

require 'telegraph/parser'

Load article from Telegra.ph:

article = Telegraph::Parser::Article.load('Пять-врагов-государства-12-10')

Article contains attributes:

article.id
 => "Пять-врагов-государства-12-10"

article.title
 => "Пять врагов государства"

 article.author
 => "Алексей ШЕРСТНЕВ"

article.content
 => "<article><p><br></p>\n<figure><div class=\"figure_wrapper\">....

article.imagese.images
=> {"/6e4ecf2f73df0e2a97028.gif"=>
  "GIF89a\xF4\x01\xDC\x00\xF7\xFF\x00\x00\x00\x00/B9\x8A\x94\x8C\xAB\xB0\xAA\x15\x18!z\x87\x840\x01\x05&)1\xC7\xA0\xA0WffK\x01\x06\x06\x14\x15\x93\n'\xA21Gvzy\xA8\x00\x12ivv)CC\x13!\x18\x....

telegraph-parser will change images names in src attribute

http://telegra.ph/file/6e4ecf2f73df0e2a97028.gif => 6e4ecf2f73df0e2a97028.gif

You can add prefix to image filenames:

article = Telegraph::Parser::Article.load('Пять-врагов-государства-12-10', image_prefix: '/static')

article.images.keys.first
=> "/static/6e4ecf2f73df0e2a97028.gif"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/svernidub/telegraph-parser.

License

The gem is available as open source under the terms of the MIT License.