Nokogiri 只查找入站链接
我有一个 html 文档位于 http://somedomain.com/somedir/example.html
该文档包含四个链接:
http://otherdomain.com/other.html
http://somedomain.com/other.html
/only.html
test.html
如何获取完整网址当前域中的链接?
我的意思是我应该得到:
http://somedomain.com/other.html
http://somedomain.com/only.html
http://somedomain.com/somedir/test.html
第一个链接应被忽略,因为它与我的域不匹配
I have an html document located on http://somedomain.com/somedir/example.html
The document contains of four links:
http://otherdomain.com/other.html
http://somedomain.com/other.html
/only.html
test.html
How I can get the full urls for the links in the current domain ?
I mean I should get:
http://somedomain.com/other.html
http://somedomain.com/only.html
http://somedomain.com/somedir/test.html
The first link should be ignored because it does'nt match my domain
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样的东西
Something like
使用正则表达式从 href="URL" 中提取链接
如果域不以“http”开头,则与域连接
这是一个 Python 示例:
use a regular expression to extract the links from href="URL"
then concatenate with the domain if it doesn't start with "http"
Here is a Python example: