Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_posts raises exception #2

Closed
jankeesvw opened this issue Jul 11, 2019 · 6 comments
Closed

get_posts raises exception #2

jankeesvw opened this issue Jul 11, 2019 · 6 comments

Comments

@jankeesvw
Copy link

Instagrammer.new("feistyfavorites").get_posts(1)

Raises:

⚠️ expected to find json_ld nil at least 1 time but there were no matches

/Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.25.0/lib/capybara/node/finders.rb:253:in `block in all': expected to find json_ld nil at least 1 time but there were no matches (Capybara::ExpectationNotMet)
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.25.0/lib/capybara/node/base.rb:83:in `synchronize'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.25.0/lib/capybara/node/finders.rb:251:in `all'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.25.0/lib/capybara/node/finders.rb:281:in `first'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/capybara-3.25.0/lib/capybara/session.rb:749:in `block (2 levels) in <class:Session>'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/post.rb:61:in `visit_page'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/post.rb:10:in `initialize'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/user.rb:95:in `new'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/user.rb:95:in `block in get_posts'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/user.rb:95:in `collect'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/instagrammer-0.1.3/lib/instagrammer/user.rb:95:in `get_posts'
	from /Users/jankeesvw/Library/Preferences/RubyMine2019.1/scratches/scratch_4.rb:1:in `<main>'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.3/lib/rails/commands/runner/runner_command.rb:38:in `perform'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<main>'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
	from /Users/jankeesvw/Documents/project/bin/rails:9:in `<main>'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `block in load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/jankeesvw/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from -e:1:in `<main>'

Process finished with exit code 1

Do you think I should patch this gem to make this work?

@jankeesvw
Copy link
Author

@richardvenneman
Copy link
Owner

Hi @jankeesvw, thanks for the report.

It seems Instagram, for reasons unknown, doesn't expose the post metadata as a JSON+LD object on all posts (https://www.instagram.com/p/BzFv6Z5oAUX/ in this case).

For users this is also the case and I support this case by checking for the existence of this metadata before scraping. It appears we're going to have to do the same for posts as well. Will work on this asap!

@jankeesvw
Copy link
Author

I can also make the patch if you want?

@richardvenneman
Copy link
Owner

@jankeesvw Sure! I'd be happy to accept a pull request 😄

richardvenneman added a commit that referenced this issue Jul 14, 2019
- Lazy get data
- Get page status before getting data, addresses #2
@richardvenneman
Copy link
Owner

@jankeesvw I just released 0.2.1 which resolves this issue.

@jankeesvw
Copy link
Author

Thanks! ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants