无法直接存取跨域站点,你可以利用XMLHTTP获取返回的源代码,然后对其进行分析

解决方案 »

  1.   

    我一年前写过搜索google,baidu得到关键字的网页数量(纯javascript)给你一点思路
    1.显示google在你在iframe中
    2.将iframe的源文件显示在textarea中
    3.提取textarea中符合要求的数据
    注意编码问题给你几个函数,读取源文件时会用到的
    text3.value=bytes2bstr(loadContent(document.getElementById("ifra2").src))
    text3.value=loadUTF8(document.getElementById("ifra2").src)
    function loadUTF8(strURL) //for google (used for "function f_inpu3()")
    {
    var strContent = "";
    if (typeof strURL != "string" || strURL == "")return strContent;
    try
    {
    var oProxy = new ActiveXObject("Microsoft.XMLHTTP");

    oProxy["Open"]("GET", strURL, false);
    oProxy["Send"]();
    strContent = oProxy["responseText"]; //get Text html
    /// strContent = oProxy["responseBody"]; //get Bin html, and then change2text
    }
    catch(e){status = e.description}
    return strContent;
    }
    function loadContent(strURL) //I get this code from a friend (used for "function f_inpu3()")
    {
    var strContent = "";
    if (typeof strURL != "string" || strURL == "")return strContent;
    try
    {
    var oProxy = new ActiveXObject("Microsoft.XMLHTTP");

    oProxy["Open"]("GET", strURL, false);
    oProxy["Send"]();
    /// strContent = oProxy["responseText"]; //get Text html
    strContent = oProxy["responseBody"]; //get Bin html, and then change2text
    }
    catch(e){status = e.description}
    return strContent;
    }
    function bytes2bstr(vin) //Have this code from a friend (used for "function f_inpu3()")
    {
    var st = new ActiveXObject("adodb.stream")
    with (st){
    Type = 2 //var adTypeBinary = 1; var adTypeText = 2
    Open()
    WriteText(vin)
    Position = 0
    Charset = "GB2312"
    Position = 2
    return ReadText
    }
    }
      

  2.   

    看看这个行吗?<script>function loadUTF8(strURL)
    {
    var strContent = "";
    if (typeof strURL != "string" || strURL == "")return strContent;
    try
    {
    var oProxy = new ActiveXObject("Microsoft.XMLHTTP");

    oProxy["Open"]("GET", strURL, false);
    oProxy["Send"]();
    strContent = oProxy["responseText"]; //get Text html
    // strContent = oProxy["responseBody"]; //get Bin html, and then change2text
    }
    catch(e){status = e.description}
    return strContent;
    }function window.onload(){
    text1.value = loadUTF8(document.getElementById("iframe1").src)
    }</script><iframe id='iframe1' src='http://www1.5460.net/gy5460/jsp/login/gongneng.jsp?csid=6081498'></iframe><p><textarea id='text1' rows=50 cols=100></textarea><p>