本例测试效果图:


代码文件:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls; type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation {$R *.dfm} uses MsXML, SuperObject; //这是将字符串转换成 UTF 编码的函数, 这里用于 Google 的搜索地址
function ToUTF8Encode(str: string): string;
var
  b: Byte;
begin
  for b in BytesOf(UTF8Encode(str)) do
    Result := Format('%s%s%.2x', [Result, '%', b]);
end; //这是给 ISuperObject 准备的方法
procedure Proc(const This, Params: ISuperObject; var Result: ISuperObject);
var
  jo: ISuperObject;
begin
  Form1.Memo1.Clear;
  for jo in Params['responseData.results'] do with Form1.Memo1.Lines do
  begin
    Add(jo.Format('%titleNoFormatting%:'));
    Add(jo.Format('%unescapedUrl%'));
    Add(EmptyStr);
  end;
end; procedure TForm1.Button1Click(Sender: TObject);
const
  u = 'http://www.google.cn/uds/GwebSearch?callback=response&rsz=large&v=1.0&q=';
var
  jo: ISuperObject;
  req: IXMLHTTPRequest;
  url: WideString;
begin
  jo := SO;
  jo.M['response'] := @Proc; {搜索结果将是类似 response(...) 函数格式的字符串}   url := u + ToUTF8Encode(Edit1.Text); {准备搜索地址}   //搜索
  req := CoXMLHTTP.Create;
  req.open('Get', url, False, EmptyParam, EmptyParam);
  req.send(EmptyParam);   //搜索结果在 req.responseText(后付其全部内容), 下面语句将调用上面的 Proc 过程.
  jo[req.responseText]; {这是在本系列"方法"一节用到的第二种调用方法}
end; end.

窗体文件:


object Form1: TForm1
  Left =
  Top =
  Caption = 'Form1'
  ClientHeight =
  ClientWidth =
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch =
  TextHeight =
  object Memo1: TMemo
    Left =
    Top =
    Width =
    Height =
    Align = alLeft
    Lines.Strings = (
      'Memo1')
    ScrollBars = ssBoth
    TabOrder =
    ExplicitHeight =
  end
  object Button1: TButton
    Left =
    Top =
    Width =
    Height =
    Caption = 'Button1'
    TabOrder =
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left =
    Top =
    Width =
    Height =
    TabOrder =
    Text = 'Delphi'
  end
end

下面是我以 "Delphi" 为关键字搜索返回的 responseText, 可以做个搜索工具了:

response(
{
"responseStatus": 200,
"responseData": {
"cursor": {
"pages": [
{
"label": 1,
"start": "0"
},{
"label": 2,
"start": "8"
},{
"label": 3,
"start": "16"
},{
"label": 4,
"start": "24"
},{
"label": 5,
"start": "32"
},{
"label": 6,
"start": "40"
},{
"label": 7,
"start": "48"
},{
"label": 8,
"start": "56"
}],
"currentPageIndex": 0,
"estimatedResultCount": "6050000",
"moreResultsUrl": "http:\/\/www.google.cn\/search?oe=utf8&ie=utf8&source=uds&start=0&hl=zh-CN&q=Delphi"
},
"results": [
{
"titleNoFormatting": "『Delphi园地』-源码,控件,文档,工具,免费下载,建设专业Delphi资源平台",
"url": "http:\/\/www.delphifans.com\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:gxlSlu0OTqQJ:www.delphifans.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.delphifans.com",
"content": "提供Delhpi技巧文章、源码、控件、文档、工具等。",
"title": "『<b>Delphi<\/b>园地』-源码,控件,文档,工具,免费下载,建设专业<b>Delphi<\/b>资源平台",
"unescapedUrl": "http:\/\/www.delphifans.com\/"
},{
"titleNoFormatting": "Delphi - 维基百科,自由的百科全书",
"url": "http:\/\/zh.wikipedia.org\/wiki\/Delphi",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:KPWnJZ_ZuuQJ:zh.wikipedia.org",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "zh.wikipedia.org",
"content": "<b>Delphi<\/b>,是Windows平台下的著名快速应用程序开发工具(Rapid Application Development ,简称RAD)。它的前身是在DOS下的产品BorlandTurbo Pascal,最早的版本由 <b>...<\/b>",
"title": "<b>Delphi<\/b> - 维基百科,自由的百科全书",
"unescapedUrl": "http:\/\/zh.wikipedia.org\/wiki\/Delphi"
},{
"titleNoFormatting": "DELPHI盒子- Delphi源代码控件文档工具下载",
"url": "http:\/\/www.2ccc.com\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:CF650RgvoJkJ:www.2ccc.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.2ccc.com",
"content": "<b>DELPHI<\/b>源代码、组件、例子、演示及相关工具下载,文档发布,全站包含论坛,笔记等功能 ,每天更新。",
"title": "<b>DELPHI<\/b>盒子- <b>Delphi<\/b>源代码控件文档工具下载",
"unescapedUrl": "http:\/\/www.2ccc.com\/"
},{
"titleNoFormatting": "编程中国>> 技术教程>> 开发语言>> Delphi",
"url": "http:\/\/www.bccn.net\/Article\/kfyy\/delphi\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:vjiBcr2xV14J:www.bccn.net",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.bccn.net",
"content": "普通文章, 第二章<b>Delphi<\/b>面向对象的编程方法(一), 06-25. 普通文章 <b>...<\/b> 普通文章, 用 <b>Delphi<\/b>制作以浏览器为界面的应用程序, 08-30. 普通文章, <b>Delphi<\/b> 中串口通讯的实现 <b>...<\/b>",
"title": "编程中国>> 技术教程>> 开发语言>> <b>Delphi<\/b>",
"unescapedUrl": "http:\/\/www.bccn.net\/Article\/kfyy\/delphi\/"
},{
"titleNoFormatting": "Delphi is a leading global supplier for the automotive, computing ...",
"url": "http:\/\/www.delphi.com\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:r5kD35m3Ns0J:www.delphi.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.delphi.com",
"content": "Supplier of audio systems, modules, and components to manufacturers and replacement parts to the after market worldwide.",
"title": "<b>Delphi<\/b> is a leading global supplier for the automotive, computing <b>...<\/b>",
"unescapedUrl": "http:\/\/www.delphi.com\/"
},{
"titleNoFormatting": "delphi 窑洞",
"url": "http:\/\/www.51delphi.com\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:Kgv5hBXmSFgJ:www.51delphi.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.51delphi.com",
"content": "基于<b>Delphi<\/b> 的Rich Internet Application开发和应用平台 。 <b>...<\/b> 61449, <b>Delphi<\/b> 7的 Property OldCreateOrder does not exist(1786字节), javer007, 2009-10-12 14:42:48 <b>...<\/b>",
"title": "<b>delphi<\/b> 窑洞",
"unescapedUrl": "http:\/\/www.51delphi.com\/"
},{
"titleNoFormatting": "delphi专栏_软件开发_最专业的程序开发网站_开发者网络_软件_天极网",
"url": "http:\/\/dev.yesky.com\/ysdevdelphi\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:j-qd-w9ESrwJ:dev.yesky.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "dev.yesky.com",
"content": "在<b>Delphi<\/b>数据库应用系统的数据录入过程中,有些数据是保存在Excel中的;有些是保存 <b>...<\/b> 为了便于开发数据库应用程序,在<b>Delphi<\/b>集成开发环境中,提供了大量的数据库工具 <b>...<\/b>",
"title": "<b>delphi<\/b>专栏_软件开发_最专业的程序开发网站_开发者网络_软件_天极网",
"unescapedUrl": "http:\/\/dev.yesky.com\/ysdevdelphi\/"
},{
"titleNoFormatting": "Delphi俱乐部",
"url": "http:\/\/www.tommstudio.com\/",
"cacheUrl": "http:\/\/www.google.com\/search?q=cache:9JQ4L48RA1QJ:www.tommstudio.com",
"GsearchResultClass": "GwebSearch",
"visibleUrl": "www.tommstudio.com",
"content": "dephi俱乐部,c#,<b>delphi<\/b>,<b>delphi<\/b>控件,<b>delphi<\/b>源码,<b>delphi<\/b>书籍,商业源码,程序开发,源码 交易,开发,方案, <b>...<\/b> Net,Java,PowerBuilder,PHP,ASP,PERL 免费源码下载,<b>Delphi<\/b>俱乐部 .",
"title": "<b>Delphi<\/b>俱乐部",
"unescapedUrl": "http:\/\/www.tommstudio.com\/"
}]
},
"responseDetails": null
}
)

XE3随笔17:实例 - 模拟 Google 搜索的更多相关文章

  1. Google搜索命令语法大全

    以下是目前所有的Google搜索命令语法,它不同于Google的帮助文档,因为这里介绍 了几个Google不推荐使用的命令语法.大多数的Google搜索命令语法有它特有的使用格式,希望大家能正确使用. ...

  2. 关于python抓取google搜索结果的若干问题

    关于python抓取google搜索结果的若干问题     前一段时间一直在研究如何用python抓取搜索引擎结果,在实现的过程中遇到了很多的问题,我把我遇到的问题都记录下来,希望以后遇到同样问题的童 ...

  3. GOOGLE搜索秘籍完全公开

    一,GOOGLE简介 Google(www.google.com)是一个搜索引擎,由两个斯坦福大学博士生Larry Page与Sergey Brin于1998年9月发明,Google Inc. 于19 ...

  4. 复杂的1秒--图解Google搜索技术

    谷歌(Google),一个非常成功,但又十分神秘,而且带有几分理想化色彩的互联网搜索巨人,它还是一家相当了不起的广告公司,谷歌首页上的那个搜索按钮是其年赢利200亿美元的杀手级应用,也是Interne ...

  5. 【转载】google搜索从入门到精通

    原文地址:http://www.cnblogs.com/helloIT/articles/5095668.html /***************************************** ...

  6. 使用云服务器实现Google搜索

    >>>>>>>>>>>>>>>>>>>>>>>>> ...

  7. google 搜索关键字技巧

    google 搜索关键字技巧 来源  https://www.cnblogs.com/qiudabai/articles/9143328.html inurl: 用于搜索网页上包含的URL. 这个语法 ...

  8. google搜索小技巧

    google搜索小技巧 一.总结 一句话总结:But most people may not be using Google search to its full potential.Want to ...

  9. 运营站点-开放robots后,站内google搜索数量第二天10条左右,第5天搜录9920条,可喜可贺

    开放robots后,站内google搜索数量第二天10条左右,第5天搜录9920条,可喜可贺 2014年4月29日 16:17:56 到目前为之已搜录14000多条,已有客户在网站注册,加入购物车

随机推荐

  1. 关于C中struct和union长度的详解

    这几天看<代码大全>中的第十三章---不常见的数据类型,里面讲解到了C语言中的struct以及对指针的解释,联想到以前看过相关的关于C语言中stuct长度的文章,只是现在有些淡忘了,因此今 ...

  2. JDK&JRE&JVM

    JDK:—Java Development kit  (Java开发工具包) JRE:—Java Runtime Environment (Java运行时环境) JVM:Java Virtual Ma ...

  3. [CSS]多浏览器兼容的垂直居中,兼容多个IE

    相信你都是在兼容垂直居中而烦恼,翻阅多个网站总是找不到理想的方法而苦恼,来到这里你的问题解决了!如果对你有帮助请点个赞,谢谢. 多兼容垂直居中,在IE6-9亲自测试并通过 <!doctype h ...

  4. 常用到的git,mvn,postgres,vim命令总结

    mvn: 打包: mvn package 如果想在打包的时候跳过测试: mvn package -Dmaven.test.skip=true 使用的junit测试框架, 测试: mvn test 如果 ...

  5. requirejs的使用

    requirejs的优点: 1.防止在js的加载过程中,阻止页面的渲染: 2.可以引入多个js文件: 3.可以写出重复使用的js模块: 4.有效的防止命名的冲突,通过将变量分装在模块中的方式实现: r ...

  6. maven构建过程

    [转载]原地址:http://www.cnblogs.com/xdp-gacl/p/4051690.html 上一篇只是简单介绍了一下maven入门的一些相关知识,这一篇主要是体验一下Maven高度自 ...

  7. mxnet实战系列(一)入门与跑mnist数据集

    最近在摸mxnet和tensorflow.两个我都搭起来了.tensorflow跑了不少代码,总的来说用得比较顺畅,文档很丰富,api熟悉熟悉写代码没什么问题. 今天把两个平台做了一下对比.同是跑mn ...

  8. fastcgi 性能初配 504 gateway time-out

    情况一:由于nginx默认的fastcgi进程响应缓冲区太小造成 这种情况下导致fastcgi进程被挂起,如果fastcgi服务队这个挂起处理不是很好的话,就可能提示"504 Gateway ...

  9. 我的第一个WP8.1应用总结

    我的LUMIA925已经买了很久了,想自己开发WP应用放在上面,却一直想不到有什么特别的想法和需要.前几天的事情正好让我有了这个机会. 前几天在客户机房工作的时候,同事打电话来说另一个客户由于换了电脑 ...

  10. [JSP]获取时间

    <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.uti ...