Sha256: d835bb43fc7221a8e1134448c20e609c0372489a2f777c307a1d408030be361a

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

module PictureFrom
  module Crawlers
    class TwitterCrawler

      def image_url_by_username(username)
        page = ProfilePage.new(username)
        page.avatar_image
      end

      class ProfilePage < BaseCrawler::Page
        def initialize(username)
          @page = open_url("https://twitter.com/#{username}")
        end

        def avatar_image
          @page.css('.ProfileAvatar-image').first['src'] if @page
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
picture_from-1.0.1 lib/picture_from/crawlers/twitter_crawler.rb
picture_from-1.0.0 lib/picture_from/crawlers/twitter_crawler.rb