如何导出从HTML DOM Parser检索到的所有图像? [英] How to export all images that got retrieve from HTML DOM Parser?
本文介绍了如何导出从HTML DOM Parser检索到的所有图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想
- 使用 PHP简单HTML DOM解析器
- 并将所有这些导出到我的桌面
所有
立刻。 (不
右键单击保存或屏幕截图)
- grab all the images from my website using PHP Simple HTML DOM Parser
- and export all of them to my Desktop
ALL
at once. (Not
right click save OR Screenshot )
可选
- 将所有超链接
保存到一个不错的文本文件中。
OPTIONAL
- save all the hyperlinks
into one nice text-file.
这是我的意思尝试过,
<?php include_once('/php/simple_html_dom.php'); ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML DOM Parser</title>
</head>
<body>
<?php $html = file_get_html('http://my-website.com'); ?>
<div class="row">
@foreach($html->find('img') as $img)
<div id="pic" class="col-sm-1">
{{$img}}
</div>
@endforeach
</div>
</div>
</body>
</html>
我想要加载图像,但我不知道如何将它们保存到我的电脑中。
即使有可能,我也不确定。
I get the images to load, but I am not sure how to save them into my computer. I am not sure even if it is possible.
是否有任何php函数或JS函数可以做到这一点?
Is there any php function or JS function that can do that ?
推荐答案
要将URL保存到文件,请执行以下操作:
To save the URLs to a file, do something like this:
@foreach($html->find('img') as $img)
file_put_contents('file.txt', $img."\r\n", FILE_APPEND); # this line saves URL to file
<div id="pic" class="col-sm-1">
{{$img}}
</div>
@endforeach
这篇关于如何导出从HTML DOM Parser检索到的所有图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文