scala - 如何使用 net.ruippeixotog.scalascraper 从 html 表中抓取所有链接
问题描述
我正在尝试从 http 表中提取所有链接,然后键入:
doc >> elementList(".countries")
我已经停在这个 html 上:
<tr class="countries" valign="top">
<td nowrap> </td>
<td nowrap>
<a href="https://ar.indeed.com/"><img src="/images/flags/ar.png"></a>
<a href="https://ar.indeed.com/">Argentina</a> <br>
<a href="https://au.indeed.com/"><img src="/images/flags/au.png"></a>
<a href="https://au.indeed.com/">Australia</a> <br>
<a href="https://at.indeed.com/"><img src="/images/flags/at.png"></a>
<a href="https://at.indeed.com/">Austria</a> <br>
</td>
</tr>
现在我想从中获取所有链接。
当我输入:
doc >> elementList(".countries") >> attr("href")("a")`
然后我只得到第一个链接:
https://ar.indeed.com/
解决方案
使用attrs
代替attr
:
doc >> elementList(".countries") >> attrs("href")("a")`
推荐阅读
- wordpress - 不要将用户重定向到 wp-comments-post.php 而是直接在输入字段中显示 required
- javascript - 使用 setTimeout ( ReactJs) 在一段时间后渲染一个组件
- configuration - 创建 React App Rewired 应用程序忽略 jest.config.js
- xamarin.android - 带有远程 url 的 AnimatedImageDrawable
- java - 如何使用 java.class 中的窗口管理器参数使 Fultter(材料按钮)覆盖显示在顶部?
- azure - 使用 Terraform 创建 Azure IaaS 域控制器
- c++ - 将扫描线写入文件c ++时出现libjpeg-turbo分段错误
- sql - 我需要显示代理主管的薪水
- c# - LINQ 按同一列连接多个表
- reactjs - CRUD API React - 方法不允许 405