0
我需要从给定网站的URL中的所有背景图片在Rails脚本解析为网站
我与引入nokogiri尝试过的背景图像的URL的外部CSS:
doc = Nokogiri::HTML(open(url)) // url - will be any website
这里是网站HTML和CSS:
<h1 class="logo">
<a href="/">Website Name</a>
</h1>
.logo {
width: 193px;
height: 73px;
float: left;
background: url(/themes/site_themes/tccc/images/logo.png) no-repeat;
}
我想要实现的是从外部文件检索徽标背景图像URL。 我们可以用Nokogiri检索内联样式,但我一直无法找到外部样式的解决方案。
我想用任何Web Scrapper从提供的网站获取所有背景图像。
我该如何做到这一点?
这是一个愚蠢的http://stackoverflow.com/questions/16917542/extract-background-image-from-an-html-element-in-ruby? – orde
你不能用Nokogiri做到这一点。您需要Watir或Selenium或其他Ruby控制浏览器。有关更多详细信息,请参见[类似的问题](http://stackoverflow.com/questions/16917542/extract-background-image-from-an-html-element-in-ruby)。 – Phrogz
感谢您的回复。@还有一个类似的问题和更详细的说明。 –