在css中将相对路径更改为完整路径
我正在使用简单的 html dom 从网站中提取数据并对其进行分段。然而,我无法将样式标签中的相对路径之一更改为完整路径。我尝试过很多组合。
我在这里找到了一篇文章,使用带有简单 html dom 的 PEAR 脚本,它适用于除下面之外的所有链接。
require_once 'includes/URL2.php';
$uri = new Net_URL2('http://www.stormcinemas.ie'); // URI of the resource
$baseURI = $uri;
foreach ($htmlcss->find('background[url]') as $elem) {
$elem->url = $baseURI->resolve($elem->url)->__toString();
}
foreach ($html->find('*[src]') as $elem) {
$elem->src = $baseURI->resolve($elem->src)->__toString();
}
foreach ($html->find('*[href]') as $elem) {
if (strtoupper($elem->tag) === 'BASE') continue;
$elem->href = $baseURI->resolve($elem->href)->__toString();
}
foreach ($html->find('form[action]') as $elem) {
$elem->action = $baseURI->resolve($elem->action)->__toString();
}
style.css
<style>
div.spriteImgSmall { background: url(/images/css_sprites/film_sprites/smallimages_sprite.jpg); }
</style>
谢谢
I am using simple html dom to extract data from a website and pharse it. I cannot however change one of the realative paths in the style tag to a full one. I have tried many combinations.
I found a post here to use a PEAR script with simple html dom and it has worked on all links except below.
require_once 'includes/URL2.php';
$uri = new Net_URL2('http://www.stormcinemas.ie'); // URI of the resource
$baseURI = $uri;
foreach ($htmlcss->find('background[url]') as $elem) {
$elem->url = $baseURI->resolve($elem->url)->__toString();
}
foreach ($html->find('*[src]') as $elem) {
$elem->src = $baseURI->resolve($elem->src)->__toString();
}
foreach ($html->find('*[href]') as $elem) {
if (strtoupper($elem->tag) === 'BASE') continue;
$elem->href = $baseURI->resolve($elem->href)->__toString();
}
foreach ($html->find('form[action]') as $elem) {
$elem->action = $baseURI->resolve($elem->action)->__toString();
}
style.css
<style>
div.spriteImgSmall { background: url(/images/css_sprites/film_sprites/smallimages_sprite.jpg); }
</style>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此处提供了解决方案,但不幸的是被删除了。再次感谢,它确实解决了我的问题。
这是供将来参考的。
如果有人知道如何在 css 上使用简单的 html dom,我仍然会感兴趣,因为网络上没有任何东西。这甚至可能是不可能的。
The solution was provided here but was deleted unfortunately. Thanks again, it actualy did solve my question.
Here it is for future ref.
I would still be interested if someone know's how to use simple html dom on css as there is nothing anywhere on the net. It may not even be possible.