有没有办法让页面上的所有链接都相对于根目录?
例如,www.example.com/fruits/apples/apple.html我可以有一个链接说:
<a href="fruits/index.html">Back to Fruits List</a>
Run Code Online (Sandbox Code Playgroud)
这个链接是指向www.example.com/fruits/apples/fruits/index.html还是www.example.com/fruits/index.html?如果是第一个,有没有办法让它指向第二个?
我正在为自己创建一个小应用程序,我在其中运行Ruby脚本并将所有图像保存在我的博客中.
在我识别出图像文件后,我无法弄清楚如何保存图像文件.任何帮助将非常感激.
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = '[my blog url]'
doc = Nokogiri::HTML(open(url))
doc.css("img").each do |item|
#something
end
Run Code Online (Sandbox Code Playgroud) 如何使用Nokogiri刮取特定URL上的图像?如果有比Nokogiri更好的选择,请建议.css图片标签是.profilePic img