吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4038|回复: 6
收起左侧

[其他原创] 编程小练习(8)

 关闭 [复制链接]
zapline 发表于 2010-3-8 12:44
我们打开一个查询IP的网站,例如http://www.123cha.com/ip/
这时我们能得到我们的IP和一些IP相关的信息

题目:
编程实现获取访问这个网站返回的信息,以便于获取查询IP相关的信息

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

obaby 发表于 2010-3-8 14:18
本帖最后由 obaby 于 2010-3-9 09:35 编辑

ip.png
unit ip;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP,OleCtrls,ComObj ;

type
  TForm1 = class(TForm)
    mmo1: TMemo;
    Button1: TButton;
    edt1: TEdit;
    lbl1: TLabel;
    idhtp: TIdHTTP;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
var
   xml : OleVariant;
   r:string;
   p1,p2 : Integer;
   I:Integer;
begin
   xml := CreateOleObject('Microsoft.XMLHTTP');
   xml.Open('GET','http://www.123cha.com/ip/?q='+edt1.Text, False);
   xml.Send;
   r := xml.responseText;
   p1:=Pos('数据</font>',r);
   p2:=Pos('<li>[查询提供]',r);
   mmo1.lines.add(' 您查询的地址可能归属地是:') ;
   mmo1.lines.add(' ===========================') ;
   mmo1.Lines.add (Copy(r, p1+16, p2-p1-5));
   mmo1.Text:=StringReplace(mmo1.Text,' ','',[rfReplaceAll]);
   mmo1.Text:=StringReplace(mmo1.Text,'</li>','',[rfReplaceAll]);
   mmo1.Text:=StringReplace(mmo1.Text,'<li>','',[rfReplaceAll]);
   mmo1.Text:=StringReplace(mmo1.Text,'<font color="blue">','',[rfReplaceAll]);
   mmo1.Text:=StringReplace(mmo1.Text,'</font>','',[rfReplaceAll]);
end;
Project1.rar (463.02 KB, 下载次数: 0) 补上编译后的exe。
dzeo 发表于 2010-3-8 14:46
VB6.0

比较笨的方法

QQ截图未命名.jpg
 
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.cz88.net/ip/viewip468.aspx"
Me.Caption = "你的IP"
End Sub
Private Sub WebBrowser1_DownloadComplete()'网页加载完成后激发
Print WebBrowser1.Document.body.outertext  '显示当前网址的文字信息
End Sub
1zm 发表于 2010-3-8 15:30
obaby 发表于 2010-3-8 15:48
最简单的方法就是加一个webbroser控件,然后载入指定的网址即可。
roxiel 发表于 2010-3-9 14:15
回复 1# zapline
  <html>
  <div align="center"> 
 <FORM name=ipform onsubmit="return checkIP();" action=http://www.ip138.com/ips.asp method=get 
  target=_blank>
  <TR>
    <TD align=middle>
      <DIV align=center>
      <P> </P>
      <P>IP地址或者域名:<INPUT size=16 name=ip> 
    <INPUT type=submit value=查询></P></DIV></TD></TR></FORM>
  </div>
  </html>
 楼主| zapline 发表于 2010-3-9 15:44
回复  zapline
roxiel 发表于 2010-3-9 14:15



    目的不对啊  是为了把BS模式改成CS模式
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-27 02:21

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表