私はこのコードを使用して、Google検索のエントリの検索結果のタイトルを取得します。しかし、"href"タグタグにリンクが必要です。サンプルコードは、Google検索結果からのリンクの取得
<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)
詳しい情報はあなたを助けるために必要とされています。このリンクを参照してください:https://stackoverflow.com/help/how-to-ask – Radio