delphi 中如何过滤网页中的内容! 获得一个页面的网址,然后就是把网页中的文章取出来!多谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mStr := IdHttp1.Get(mUrl);mStr即为网页的内容,过滤方法是先分析mStr的特点,找到关键的子字符串,然后在mStr里定位子字符串的位置,剔除无用字符串即可。 http://news3.xinhuanet.com/politics/2006-07/09/content_4810516.htm分页可不考虑,多谢了! unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, StrUtils;type TForm1 = class(TForm) IdHTTP1: TIdHTTP; Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var mStr: string; mKey1,mKey2: string;begin mKey1 := '<P><STRONG><FONT color=#0000ff> '; mKey2 := '<P align="center" class="pagelink">'; mStr := IdHttp1.Get('http://news3.xinhuanet.com/politics/2006-07/09/content_4810516.htm'); //根据关键字找到文章开始部分 mStr := RightBStr(mStr,Length(mStr)-Pos(mKey1,mStr)+1); //根据关键字找到文章结束部分 mStr := LeftBStr(mStr,Pos(mKey2,mStr)-1); Memo1.Lines.Clear; Memo1.Lines.Add(mStr);end;end. mStr里面还有些html的标记,你可以找到位置后,用delete函数去除掉,具体请看一下这个函数的帮助吧。 DBNavigator 图片 在Form上如何选择多个控件? 有关delphi类成员指定的问题? 怎么获得一个类的实例个数?如我的FORM上增加了5个BUTTON,我怎么在程序中获知TButton的实例有5个啊? OOP全面解释 疑难问题,疑难问题啊!!救救我! IPHONE和Android都可用的「热门软件」开发源码 delphi模仿163上传附件,可以添加多个文件,文件重复了提示,将文件以流的形式保存到数据库中怎么办?急! why?为什么会是这样的? delphi可以只改变Label的字体高度吗? DBcombobox录入问题? 如何读取内存里的数值,请高手进!
分页可不考虑,多谢了!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, StrUtils;type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
mStr: string;
mKey1,mKey2: string;
begin
mKey1 := '<P><STRONG><FONT color=#0000ff> ';
mKey2 := '<P align="center" class="pagelink">';
mStr := IdHttp1.Get('http://news3.xinhuanet.com/politics/2006-07/09/content_4810516.htm');
//根据关键字找到文章开始部分
mStr := RightBStr(mStr,Length(mStr)-Pos(mKey1,mStr)+1);
//根据关键字找到文章结束部分
mStr := LeftBStr(mStr,Pos(mKey2,mStr)-1);
Memo1.Lines.Clear;
Memo1.Lines.Add(mStr);
end;end.