Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use Ruby method, <code>sleep</code></p> <pre class="lang-rb prettyprint-override"><code>seconds_to_delay = 5 sleep seconds_to_delay </code></pre> <hr> <p>Edit 1: Dealing with divs that load some time after the document finishes loading</p> <p>I hate this scenario. I had to deal with exact same scenario, so here's how I solved it. You need to use something like <a href="http://rubygems.org/gems/selenium-webdriver" rel="nofollow">selenium-webdriver</a> gem.</p> <pre class="lang-rb prettyprint-override"><code>require 'selenium-webdriver' url = "http://techcrunch.com/search/education#stq=education&amp;stp=1" css_selector = ".tab-panel.active" driver = Selenium::WebDriver.for :firefox driver.get(url) driver.switch_to.default_content posts_text = driver.find_element(:css, css_selector).text puts posts_text driver.quit </code></pre> <p>If you are running this on some virtual machine on Heroku, AWS EC2 or Digital Ocean and stuff, you can't use firefox. Instead you need a headless browser like phantom.js.</p> <p>In order to use phantom.js instead of firefox, first, install phantomjs on the VM. Then change to <code>driver = Selenium::WebDriver.for :phantomjs</code>.</p> <p>You can use <a href="https://rubygems.org/gems/phantomjs" rel="nofollow">this gem</a> that actually installs phantomjs for you.</p> <hr> <p>Second edit for question b)</p> <pre class="lang-rb prettyprint-override"><code>require 'selenium-webdriver' url = "http://techcrunch.com/search/education#stq=education&amp;stp=1" css_selector = ".tab-panel.active ul.river-compact.river-search li" driver = Selenium::WebDriver.for :phantomjs driver.get(url) driver.switch_to.default_content items = driver.find_elements(:css, css_selector) items.each {|x| puts x } driver.quit </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload