用什么方法可以提取 .html 文件里面的内容
或者是将 .html 还原成源码存到 .txt文件中去,然后再提取我所需要的特定内容。
各位大哥,给个思路,最好能举个例子,谢谢!! 分数不是问题
或者是将 .html 还原成源码存到 .txt文件中去,然后再提取我所需要的特定内容。
各位大哥,给个思路,最好能举个例子,谢谢!! 分数不是问题
解决方案 »
- 请问怎么用点号.构建RzCheckTree呢?
- 数据更新问题
- 如何在前台刷新没有主键的表
- 求一函数实现:将文本文件中指定的字符串替换为另一个字符串
- 用serversocket和clientsocket实现服务器通过button, 向客户端发信息 ,应该咋实现啊?给点思路啊
- [Error] ***.dpk(67): RLINK32: Error opening file "D:\****\****.drf"
- ABC 问题。
- 5.0还是6.0
- 如何解决Aceess 在局域网通过 链接表搜索,时间长问题
- treeview 控件问题,
- 怎样处理一个3M多的文本文件?
- 这样的语句为什么在Oracle中应该怎么写?(Sql server 中没问题)
begin
//WebBrowser1.Navigate(PChar('http://www.yiwant.com/cgi-bin/sn.cgi'),
WebBrowser1.Navigate(PChar('http://www.yiwant.com/shouji114.htm'),
EmptyParam,EmptyParam,EmptyParam,EmptyParam);
IsFind:= false;
end;procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
i: Integer;
IDoc: IHTMLDocument2;
iELC : IHTMLElementCollection ;
S : string;
HtmlInputEle : IHTMLInputElement;
HtmlEle: IHTMLElement;
//HtmlSelEle : IHTMLSelectElement;
spDisp: IDispatch;
//HtmlEleCol: IHTMLElementCollection;
ovDoc: oleVariant;
begin
IDoc:= WebBrowser1.Document as IHTMLDocument2;
iELC:= IDoc.Get_all;
for i:=0 to iELC.length-1 do
begin
Application.ProcessMessages;
Sleep(10);
spDisp:= iELC.item(i,0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle)) then
begin
s:= HtmlInputEle.name; if ((HtmlInputEle.type_ = 'text') and
(HtmlInputEle.name = 'keyword')) then
begin
HtmlInputEle.value:= Edit1.Text;
end;
if ((HtmlInputEle.type_ = 'submit') and
(HtmlInputEle.value = '提交')) then
begin
HtmlInputEle.form.submit;
s:=HtmlInputEle.form.action;
//Memo1.Lines.Add(s);
end;
end;
end;
if SUCCEEDED(spDisp.QueryInterface(IHTMLElement, HTMLEle)) then
begin
//Memo2.Lines.Add(HTMLEle.className);
ovDoc:= (Sender as TWebBrowser).Document;
s:= ovDoc.All.item.innerhtml;
//Memo2.Text:= s;
Label1.Caption:= SearchPlace(s);
//if s <>'' then
//WebBrowser1.Stop;
end;
end;function TForm1.SearchPlace(sPlace: String): String;
var
iPos: Integer;
s: String;
begin
//s:= 'sorry,Nothing!';
iPos:= pos(Edit1.Text,sPlace);
if iPos > 0 then
begin
sPlace:= Copy(sPlace,iPos,Length(sPlace));
iPos:= Pos('align=center>',sPlace);
if iPos > 0 then
begin
sPlace:= Copy(sPlace,iPos+13 ,Length(sPlace));
iPos:= Pos('</P></TD>',sPlace);
if iPos > 0 then
begin
s:= Copy(sPlace,1,iPos-1);
end;
end;
end;
if s<>'' then WebBrowser1.Stop;
if s = '没搞错吗?那真是不好意思了。' then
s:= 'sorry,没有找到!';
IsFind:= false;
Result:= s;
end;以上是我做的一个查手机所属地的关键源代码,其实现算法很简单
先找到网页中的edit和button控件,然后辅值后提交(submit),页面显示完成后得到整个网页的源代码,然后通过字符串分析得到手机的归属地,你看看,应该对你有用的
以提取该网页中一些所需要的文字,要是能够将 .html 文件还原成源码提取出来存为 .txt文件 然后对 txt文件进行操作也可以,拜托,帮帮忙!!!!
然后:Memo1.Lines.LoadFromFile('c:\lhp.html');