用js 怎么采集网页信息啊,别用 j q....这个还是第一次做有知道的不?

解决方案 »

  1.   

    什么信息  文档信息 用document     用的最多
      

  2.   

    就是采集别的网站的信息。比如 www.baidu.com这个网页中的一句话。。
      

  3.   

    用这样的写法好像不行啊?
    function ajaxFunction()
     {
     var xmlHttp;
     
     try
        {
       // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
     catch (e)
        {  // Internet Explorer
       try
          {
          xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
       catch (e)
          {      try
             {
             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
             }
          catch (e)
             {
             alert("您的浏览器不支持AJAX!");
             return false;
             }
          }
        }

        xmlHttp.onreadystatechange=function()
          {
          if(xmlHttp.readyState==4)
            {
             alert(xmlHttp.responseText);
            }
          }
        xmlHttp.open("POST","www.baidu.com",true);
        xmlHttp.send(null);

     }
     ajaxFunction();
      

  4.   

    try:
    xmlHttp.open("GET","www.baidu.com",true);
    xmlHttp.send(null);
      

  5.   


    <script>
    function createXMLHttpRequest()
    {
    if (window.ActiveXObject)
    {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      else if(window.XMLHttpRequest)
      {
       xmlHttp = new XMLHttpRequest();
      }
    }function startRequest()
    {
    createXMLHttpRequest();
    xmlHttp.onreadystatechange = handleStateChange;
    xmlHttp.open("GET", "http://www.baidu.com", true);
    xmlHttp.send(null);
    }function handleStateChange()
    {
    if(xmlHttp.readyState == 4)
    {
    if(xmlHttp.status == 200)
    {
     result = xmlHttp.responseText;
     alert("The server replied with:" + result);
     
     alert(result.substring(result.indexOf("<title>")+7,result.indexOf("</title>")));
    }else
    {
    //alert(xmlHttp.status);
      }
    }else{
       window.status = xmlHttp.readyState;
    }
    }
    startRequest();
    </script>
      

  6.   

    虽然你说了不用jquery,不过还是建议你用jquery.呵呵
      

  7.   

     谢谢windzjp
    我的错在这里了xmlHttp.open("GET", "http://www.baidu.com", true);
    我不用jq是因为不能因为这一个简单的需求就重新添加一个js库,其他的地方都没有用到jq.已经搞定.. 谢谢回答问题的所有人,,,,