rubycdp / vessel

Fast high-level web crawling Ruby framework
https://vessel.rubycdp.com
MIT License
645 stars 11 forks source link

How can I do scrolling? #13

Closed AndreyAzimov closed 3 years ago

AndreyAzimov commented 3 years ago

Can you please suggest how can I do scrolling inside the parse method?

I tried all of bellow, but no one of these seems to work (undefined local variable or method): mouse.scroll_to(0, 1000) ferum.mouse.scroll_to(0, 1000) browser.mouse.scroll_to(0, 1000) self.mouse.scroll_to(0, 1000)

I can access selector methods like xpath, at_xpath, css, at_css directly inside the parse method, but how can I access mouse?

P.S. I'm a newbie, so sorry if this question sounds dump. Thanks.

Mifrill commented 3 years ago

@AndreyAzimov no problem, thanks for the question. The "Ferrum" methods should be available by page reference: https://github.com/rubycdp/vessel/blob/61b0f581d577b446d35af1fd58a088195ba69642/lib/vessel/cargo.rb#L77 like this: page.mouse.scroll_to(0, 1000)

as same as xpath/at_xpath etc by delegate: https://github.com/rubycdp/vessel/blob/61b0f581d577b446d35af1fd58a088195ba69642/lib/vessel/cargo.rb#L75

AndreyAzimov commented 3 years ago

Thanks for the quick reply! It helped!