小偷程序:把远程网站上的数据(图片,网页及其他文件)抓取到本地,处理后再显示
正则表达式:
用于字符串的模式分割 、匹配、查找及替换操作。
相关函数:
int ereg ( string $pattern
, string $string
[, array &$regs
] )
若省略参数返回的数组,找到则返回值为 True 否则 返回 False
eregi() 不区分大小写。
读取整个文件,比如:
用此函数可以获取网页信息
他就是小偷程序的基础。
比如:
<?php
http://www.ubuntu.org.cn/index_kylin");
echo $url;
?>
但是对于另一个网站:
<?php
http://www.alangzhong.com/index.html");
echo $url;
?>
发现很多的背景图片是看不见的。
查看网页源代码我们发现,这是
<img width="116" height="98"
src="/upload/201503/b123ec26-bb8f-43be-b5ad-cdf45153d053.png"/>
图片的地址使用了相对路径,而我们本地没有这样的文件,当然显示不出来。
用正则表达式选定图片,然后远程地址替换相对路径:
下面代码的超时问题没有解决。