ruby - Fetching links from google search results -


i have code gives me title of search results of google search entry. i want links in "href" tag tag. example code

<h3 class="r"><a href="https://www.lonelyplanet.com/india" onmousedown="return rwt(this,'','','','1','afqjcng5z2tyca5rni1x_vky3gt9bevs4w','','0ahukewi-99jmpqxwahuko48khdfqbciqtwiijzaa','','',event)" target="_blank">lonely planet india - india - lonely planet</a></h3>    require 'mechanize' agent = mechanize.new page = agent.get("https://www.google.com/videohp") search_form = page.form('f') search_form.q = 'india' page = agent.submit(search_form) puts page.search('h3.r').map(&:text) 

page.search('h3.r a').map{|a| a['href']} 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -