zoukankan      html  css  js  c++  java
  • 网抓(XML Http Request、VBA)实现

    第一种,先看VBA

    Public Function GetInfo(strMoblie As String) As String
        '创建对象
        Dim xmlHttp As Object
        Set xmlHttp = CreateObject("MSXML2.XMLHTTP")
        '发送请求
        xmlHttp.Open "GET", "http://www.ip138.com:8080/search.asp?action=mobile&mobile=" & strMoblie, False
        xmlHttp.Send
    
       '等待响应
        Do While xmlHttp.ReadyState <> 4
            DoEvents
        Loop
       '得到请求数据
       Dim strReturn As String
       strReturn = xmlHttp.ResponseText
       GetInfo = strReturn
    End Function

    第二种,XML Http Request,是不是似曾相识呀

    <html>
    <head>
    <script type="text/javascript">
    
    xmlHttp=null;
    
    function showHint(str)
    {
    if (str.length==0)
      { 
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    try
      {// Firefox, Opera 8.0+, Safari, IE7
      xmlHttp=new XMLHttpRequest();
      }
    catch(e)
      {// Old IE
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch(e)
        {
        alert ("Your browser does not support XMLHTTP!");
        return;  
        }
      }
    url="/ajax/gethint.asp?q=" + str;
    url=url+"&sid="+Math.random();
    xmlHttp.open("GET",url,false);
    xmlHttp.send(null);
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
    }
    </script> 
    </head>
    <body><form> 
    First Name:
    <input type="text" id="txt1"
    onkeyup="showHint(this.value)">
    </form><p>Suggestions: <span id="txtHint"></span></p> </body>
    </html>

    这个先放着,回头补充。

  • 相关阅读:
    进程、线程、线程安全理解
    查日志常用Linux命令
    Spring容器管理Bean的生命周期
    在Linux模拟浏览器访问下载文件
    在windows上安装mysql
    java判断ip和端口是否通信正常
    Mongodb开启慢查询
    golang 中奇怪的空切片
    关于 MySQL sql_log_bin
    MySQL read_only 与 super_read_only 之间的关系
  • 原文地址:https://www.cnblogs.com/dlsunf/p/8574079.html
Copyright © 2011-2022 走看看