获得指定网址指定标签内的内容或代码
2010-06-04 20:07
337 查看
uses msxml; //从网页源文件中获得指定标签间的代码 function TForm1.GetStr(StrSource, StrBegin, StrEnd: string): string; var in_star, in_end: integer; begin in_star := AnsiPos(strbegin, strsource) + length(strbegin); in_end := AnsiPos(strend, strsource); Result := copy(strsource, in_star, in_end - in_star); end; //信息列表点击 procedure TForm1.btn1Click(Sender: TObject); const url = 'http://www.xxx.com'; var req: IXMLHTTPRequest; StrStream: TStringStream; SetNoteStr: string; begin //利用 IXMLHTTPRequest 获取网页源代码,在调用函数GetStr截取需要的代码 req := CoXMLHTTPRequest.Create; req.open('Get', url, False, EmptyParam, EmptyParam); req.send(EmptyParam); //获取标签直接的代码 SetNoteStr := GetStr(req.responseText, '</script></center>', 'document.body.oncopy=function'); StrStream := TStringStream.Create(SetNoteStr); try StrStream.Position := 0; //直接写入WebBrowser (WebBrowser.Document as IPersistStreamInit).Load(TStreamadapter.Create(StrStream)); finally StrStream.Free; end; end;
相关文章推荐
- 用正则获得指定标签的内容
- php获取页面指定标签内容的实现代码分享
- asp把指定网址的内容生成为PDF文件ABCPDF示例代码及破解版下载
- PHP采集指定HTML标签代码内容分享
- jquery实用代码 - 多标签切换显示内容效果
- asp获取远程网页的指定内容的实现代码
- dedeCMS中的标签"channelartlist” 来获得频道的下级栏目的内容列表
- 获取指定的内容---MXCMS ReadNews标签说明
- [JavaScript]多个表单中文件上传网址的获得的代码示例
- 【代码】用div+css实现 在新窗口中打开指定的DIV标签下链接
- 用正则表达式替换指定标签中的内容
- 修改XML指定标签的内容
- java读取文件并获得文件编码,转换为指定编码的工具类代码
- JQuery中判断一个元素下面是否有内容或者有某个标签的判断代码
- 代码训练营——File,列出指定目录下的所有内容
- 【HTML】使用iframe标签显示目标网页(内容)的指定区域(转)
- 使用vc连接指定url获得其HTML的代码
- dedeCMS中的标签"channelartlist” 来获得频道的下级栏目的内容列表
- asp把指定网址的内容生成为PDF文件ABCPDF asp 生成pdf