回复: 千君万码
"■■■■■■"是动态变化的内容, 同一个页面,
如今天是: http://www.other-web.com/567/u30NTcdKkYABZhvWn1, 明天就变了.
不能一直用这个地址, 必须每次先打开 http://www.other-web.com/123/page.htm,
再点击其中的链接, 太麻烦.
"■■■■■■"是动态变化的内容, 同一个页面,
如今天是: http://www.other-web.com/567/u30NTcdKkYABZhvWn1, 明天就变了.
不能一直用这个地址, 必须每次先打开 http://www.other-web.com/123/page.htm,
再点击其中的链接, 太麻烦.
<script>
window.onload=function(){
var url=http://www.other-web.com/123/page.htm;
getDoc(url,getLink);
}
/* 分析网页 */
function getLink(text){
var reg=/<a\s(?:(?!href\s?=\s?|>).)*href\s?=\s?["']?([^"'>]*http:\/\/www.other-web.com\/567[^"'>]*)["']?[^>]*>/i;
var m=text.match(reg);
alert(m[1]);//输出这个图片地址
}
/* 参数:要获取的文件的网址,回调函数*/
function getDoc(url,fun){
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
if(xmlhttp.status==200){
fun(xmlhttp.responseText);
}
}
}
xmlhttp.open("get",url,true);
window.startGetFileTime=new Date();
xmlhttp.send();
}
</script>