【发布时间】:2016-03-24 19:57:29
【问题描述】:
我正在使用简单的 HTML dom 解析器。 我的代码一切正常,但 jqueryui 无法正常工作,并且对于某些网站,它不显示图像。 请查看现场直播here 请尝试使用简单的 HTML dom parser。
请在带有 URL 的文本字段中输入 URL。 您可以看到图像未加载并且滑块不起作用。 这是我的代码
<?php
include_once 'simple_html_dom.php';
$data = new simple_html_dom();
if ( isset($_REQUEST['url_name']) ) {
if ( strpos($_REQUEST['url_name'], "http://") === false && strpos($_REQUEST['url_name'], "//") === false ) {
$_REQUEST['url_name']="http://".$_REQUEST['url_name'];
}
$url_name = $_REQUEST['url_name'];
if ( strpos($_REQUEST['url_name'], "/") === false ) {
$url_name = $_REQUEST['url_name'].'/';
}
// Load HTML from an URL
$data->load_file($_REQUEST['url_name']);
foreach ( $data->find('img') as $element ) {
$element->target='_blank';
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('style') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('script') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('link') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->href=$url_name.$element->href;
}
}
foreach ( $data->find('a') as $element ) {
if ( strpos($element->href, ".com") === false
&& strpos($element->href, ".net") === false
&& strpos($element->href, ".org") === false
&& strpos($element->href, "http://") === false
&& strpos($element->href, "https://") === false
){
$element->href = "form_submit.php?url_name=".$url_name.$element->href;
} else {
$element->href = "form_submit.php?url_name=".$element->href;
}
}
echo $newHtml;
}
?>
【问题讨论】:
-
请发布您的代码。
-
@Gjohn 抱歉,测试网址是 tool-super-star.c9users.io
-
@Gjohn 对于larevuedekenza.fr,所有图片尺寸都设置为0px,带有测试网址。
-
@virendra 你知道怎么解决吗?请帮帮我。
-
你实际上想用这段代码实现什么?阅读起来非常困难。小提示:如果您发现自己使用单行 cmets 描述部分代码,则应删除注释,并将该块移动到单独的函数中。
标签: javascript php jquery html jquery-ui