Class: InstagramCrawler::Parser::Json
- Defined in:
- lib/instagram_crawler/parser/json.rb
Instance Attribute Summary collapse
-
#page_info ⇒ Object
readonly
Returns the value of attribute page_info.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(page_info, user_id) ⇒ Json
constructor
A new instance of Json.
- #parsing ⇒ Object
Constructor Details
#initialize(page_info, user_id) ⇒ Json
Returns a new instance of Json.
6 7 8 9 |
# File 'lib/instagram_crawler/parser/json.rb', line 6 def initialize(page_info, user_id) @page_info = page_info @user_id = user_id end |
Instance Attribute Details
#page_info ⇒ Object (readonly)
Returns the value of attribute page_info.
4 5 6 |
# File 'lib/instagram_crawler/parser/json.rb', line 4 def page_info @page_info end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
4 5 6 |
# File 'lib/instagram_crawler/parser/json.rb', line 4 def user_id @user_id end |
Instance Method Details
#parsing ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/instagram_crawler/parser/json.rb', line 11 def parsing begin end_cursor = page_info["end_cursor"][0..-3] url = next_url(end_cursor, user_id) html = get_json(url) json = JSON.parse(html) @page_info = json["data"]["user"]["edge_owner_to_timeline_media"]["page_info"] edges = json["data"]["user"]["edge_owner_to_timeline_media"]["edges"] loop_edges(edges) end while page_info["has_next_page"] end |