无论如何,有没有要搜索并获得< a ..</a>的值? [英] Is there anyway to search and get the value of <a>.. </a>?

查看:75
本文介绍了无论如何,有没有要搜索并获得< a ..</a>的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在网页中我具有以下值:

In a webpage suppose i have the below values:

<td> <a href="https://www.test.com/test123/a.html"> test11 </a> </td>
<td> <a href="https://www.test.com/test12333/r.html"> test12 </a> </td>
<td> <a href="https://www.test.com/testaa123/t.html"> test21 </a> </td>
<td> <a href="https://www.test.com/test123123/b.html"> test31 </a> </td>

反正有使用Ruby查找值test21吗?

Is there anyway to find the value test21 using Ruby?

或者是否有找到具有子字符串/testaa123/t.htmlhref值?

Or is there anyway to find the href values which has a substring /testaa123/t.html?

推荐答案

尝试以下教程对于Nokogiri.

Try out this tutorial for Nokogiri.

<li>标签的示例:

require 'rubygems'
require 'nokogiri'   
require 'open-uri'
PAGE_URL = "http://ruby.bastardsbook.com/files/hello-webpage.html"

page.css('li')[0].text

这将从以下站点输出YouTube:

This will output YouTube from the site below:

<div id="funstuff">
   <p>Here are some entertaining links:</p>
   <ul>
      <li><a href="http://youtube.com">YouTube</a></li>
      <li><a data-category="news" href="http://reddit.com">Reddit</a></li>
      <li><a href="http://kathack.com/">Kathack</a></li>
      <li><a data-category="news" href="http://www.nytimes.com">New York Times</a></li>
  </ul>
</div>

这篇关于无论如何,有没有要搜索并获得&lt; a ..&lt;/a&gt;的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆