Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
j_api_agent / lib / j_api_agent / content_parser / statigram_parser.rb
Size: Mime:
module JApiAgent::ContentParser
  class StatigramParser < ParserBase
    def self.parse(posts)
      parsed_posts = []
      default_options = { :platform => "Instagram"}
      posts.entries.each do |p|
        pp = Post.new(default_options)
        begin
          pp.author = p.author
          doc = Nokogiri::HTML(p.summary)
          image_tags = doc.xpath('//img')
          image_src = image_tags.first['src']
          pp.post_image = image_src

          pp.content = p.title
          pp.published_date = p.published - 17.hours
        rescue nil
          pp = nil
        end
        parsed_posts << pp if pp
      end
      parsed_posts
    end
  end
end