ruby - Extracting url with capybara -


i have page multiple entries of student names, each student having url leads chart. html looks this:

<div class="student_name">   <a target="_blank" data-tn-element="grade-result-link[]" data-tn-link     href="/johndoe/b89db3308ddaaed2?sp=0" rel="nofollow" class="student_link"    itemprop="url">john doe</a>      <span class="graduated"> - graduated 2013</span> </div> 

i want create list urls of each student on page end name of student. i'm using capybara webkit , code resembles this:

results =  page.all('div.student_name').map |item|    puts(item.text) end 

how phrase can extract embedded (relative) url in href?

ed

urls = page.all('div.student_name a', minimum: 1).map |link]   link[:href] end 

should urls. minimum:1 make all wait until @ least 1 instance on page , may not needed in particular instance. depending on driver you're using may full normalized urls stripping domain off them isn't hard if need relative.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -