如何获取实时网页的内容?

haifengbei 2008-09-16 08:44:13
用VFP编写的程序可以做到吗?我还没有做过LAN的程序

比如.我要把一个网页上的内容保存为bdf或excel文件..怎么才做到?
...全文
463 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fwy12 2008-09-20
  • 打赏
  • 举报
回复
谢谢yasur的指导。
yasur 2008-09-19
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 fwy12 的回复:]


如果我想在一个表单的空白处显示网页上的连接,当点击后可以打开网页。就像360的那样,


[/Quote]

这种应用直接使用explorer控件就可以了。在VFP的控件中加入internet explorer空间即可。打开使用navigate方法。
cUrl=ALLTRIM("http://www.baidu.com")
thisform.olecontrol1.navigate(cUrl)
fwy12 2008-09-19
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 yasur 的回复:]
用XMLHTTP吧。

LOCAL oxhttp as Microsoft.xmlhttp
oxhttp=CREATEOBJECT("Microsoft.xmlhttp")
oxHttp.Open("GET","http://www.baidu.com",.f.)
oxHttp.Send()
SourceCode=oxHttp.responseBody
SourceCode=STRconv(SourceCode,2)

sourceCode就是获取到的源代码。想怎么加工都可以。
[/Quote]

如果我想在一个表单的空白处显示网页上的连接,当点击后可以打开网页。就像360的那样,

请问这段代码应该加在什么地方。
juanyebu 2008-09-16
  • 打赏
  • 举报
回复
看不懂呀
jack_wang0823 2008-09-16
  • 打赏
  • 举报
回复
DECLARE INTEGER URLDownloadToFile IN urlmon.dll;
INTEGER pCaller, STRING szURL, STRING szFileName,;
INTEGER dwReserved, INTEGER lpfnCB

LOCAL lcRemoteFile, lcLocalFile
lcRemoteFile = "http://www.baidu.com/deafindex.htm "
lcLocalFile = "c:\xxx.htm "

= URLDownloadToFile (0, lcRemoteFile, lcLocalFile, 0, 0)
haifengbei 2008-09-16
  • 打赏
  • 举报
回复
哦...虽然不是我想要的,但麻烦到你,还得说声谢谢.
十豆三 2008-09-16
  • 打赏
  • 举报
回复
就是另存,你要想生成XML等文件类型,必须给的远程地址就是这样的。
haifengbei 2008-09-16
  • 打赏
  • 举报
回复
郁闷..试过了,效果好像只是把文件另存为一样...

我用GetIESource测试了百度的主页...以下是获取的网页代码,请问,VFP能做到这种功能吗?
(如果做得到,我就可以不用第三方软件,从下面的代码中,取得我想要的资料)

<HTML><HEAD><TITLE>百度一下,你就知道</TITLE>
<META http-equiv=Content-Type content=text/html;charset=gb2312>
<STYLE>body{margin:4px 0}p{margin:0;padding:0}img{border:0}td,p,#u{font-size:12px}#b,#u,#l td,a{font-family:arial}#kw{font:16px Verdana;height:1.78em;padding-top:2px}#b{height:30px;padding-top:4px}#b,#b a{color:#77c}#u{padding-right:10px;line-height:19px;text-align:right;margin:0 0 3px !important;margin:0 0 10px}#sb{height:2em;width:5.6em}#km{height:50px}#l{margin:0 0 5px 15px}#l td{padding-left:107px}p,table{width:650px;border:0}#l td,#sb,#km{font-size:14px}#l a,#l b{margin-right:1.14em}a{color:#00c}a:active{color:#f60}#hp{position:absolute;margin-left:6px}#lg{margin:-26px 0 -44px}#lk{width:auto;line-height:18px;vertical-align:top}</STYLE>
</HEAD>
<BODY>
<DIV id=u><A href="http://passport.baidu.com/?login&tpl=mn&u=http%3A//www.baidu.com/">登录</A></DIV>
<CENTER><IMG id=lg height=129 src="http://www.baidu.com/img/baidu_logo.gif" width=270 useMap=#mp><BR><BR><BR><BR>
<TABLE id=l cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD>
<DIV id=m><A onclick=s(this) href="http://news.baidu.com">新 闻</A><B>网 页</B><A onclick=s(this) href="http://tieba.baidu.com">贴 吧</A><A onclick=s(this) href="http://zhidao.baidu.com">知 道</A><A onclick=s(this) href="http://mp3.baidu.com">MP3</A><A onclick=s(this) href="http://image.baidu.com">图 片</A><A onclick=s(this) href="http://video.baidu.com">视 频</A></DIV></TD></TR></TBODY></TABLE>
<TABLE style="MARGIN-LEFT: 15px" cellSpacing=0 cellPadding=0>
<TBODY>
<TR vAlign=top>
<TD style="PADDING-LEFT: 92px; HEIGHT: 62px" noWrap>
<FORM name=f action=/s><INPUT id=kw maxLength=100 size=42 name=wd>
<SCRIPT>var w=document.f.wd;w.focus();document.getElementById("u").innerHTML='<a href="http://passport.baidu.com/?login&tpl=mn&u='+escape(location.href)+'">登录</a>';function s(o){if(w.value.length>0){var h=o.href;var q=encodeURIComponent(w.value);if(h.indexOf("q=")!=-1){o.href=h.replace(new RegExp("q=[^&$]*"),"q="+q)}else{o.href+="?q="+q}}};(function(){if(new RegExp("q=([^&]+)").test(location.search)){w.value=decodeURIComponent(RegExp.$1)}})()</SCRIPT>
<INPUT id=sb type=submit value=百度一下> <SPAN id=hp><A href="/search/jiqiao.html">帮助</A><BR><A href="/gaoji/advanced.html">高级</A></SPAN></FORM></TD></TR></TBODY></TABLE>
<P id=km><A href="http://hi.baidu.com">空间</A>  <A onmousedown="(new Image()).src='http://s.baidu.com/w.gif?fm=index&title=hao123&t='+(new Date().getTime())" href="http://www.hao123.com">hao123</A> | <A style="FONT-FAMILY: 宋体" href="/more/">更多>></A></P>
<P style="HEIGHT: 60px">
<TABLE id=lk cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD></TD></TR></TBODY></TABLE></P>
<P style="HEIGHT: 30px"><A onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.baidu.com')" href="http://utility.baidu.com/traf/click.php?id=215&url=http://www.baidu.com">把百度设为首页</A></P>
<P style="HEIGHT: 14px"><A href="http://jingjia.baidu.com">企业推广</A> | <A href="http://top.baidu.com">搜索风云榜</A> | <A href="/home.html">关于百度</A> | <A href="http://ir.baidu.com">About Baidu</A></P>
<P id=b>?2008 Baidu <A href="http://www.baidu.com/duty/">使用百度前必读</A> <A href="http://www.miibeian.gov.cn" target=_blank>京ICP证030173号</A> <IMG src="http://gimg.baidu.com/img/gs.gif"></P><MAP name=mp><AREA title="点此进入 百度空间" shape=RECT target=_blank coords=43,22,227,91 href="http://hi.baidu.com/baidu/"></MAP></CENTER><!--e9619a3977e1e797--></BODY></HTML>
十豆三 2008-09-16
  • 打赏
  • 举报
回复
*VFP API-另存网页为文件

*------------------------

lcRemoteUrl = "http://www.163.com"
lcLocalFile = "c:\xxx.htm"

Declare Integer DeleteUrlCacheEntry In Wininet.Dll String szUrl
Declare Integer URLDownloadToFile In urlmon.Dll Integer pCaller,String szURL,;
String szFileName,Integer dwReserved,Integer lpfnCB

=DeleteUrlCacheEntry(lcRemoteUrl) &&清理缓存
If URLDownloadToFile(0,lcRemoteUrl,lcLocalFile,0,0)<>0
Messagebox('读取数据失败!',48,'信息提示')
Return
Endif
haifengbei 2008-09-16
  • 打赏
  • 举报
回复
提示:找不到lcRemoteUrl变量...
我测试时,代码全放在按键的click上...

应该要怎么做?
十豆三 2008-09-16
  • 打赏
  • 举报
回复
*VFP API-另存网页为文件

*------------------------
lcRemoteUrl = "http://www.163.com"
lcLocalFile = "c:\xxx.htm"

Declare Integer DeleteUrlCacheEntry In Wininet.Dll String szUrl
Declare Integer URLDownloadToFile In urlmon.Dll Integer pCaller,String szURL,;
String szFileName,Integer dwReserved,Integer lpfnCB

=DeleteUrlCacheEntry(lcRemoteUrl) &&清理缓存
If URLDownloadToFile(0,lcRemoteUrl,lcLocalFile,0,0)<>0
Messagebox('读取数据失败!',48,'信息提示')
Return
Endif
yrt888 2008-09-16
  • 打赏
  • 举报
回复
多谢楼上的,学习了新的下载方法,谢谢!
yasur 2008-09-16
  • 打赏
  • 举报
回复
用XMLHTTP吧。

LOCAL oxhttp as Microsoft.xmlhttp
oxhttp=CREATEOBJECT("Microsoft.xmlhttp")
oxHttp.Open("GET","http://www.baidu.com",.f.)
oxHttp.Send()
SourceCode=oxHttp.responseBody
SourceCode=STRconv(SourceCode,2)

sourceCode就是获取到的源代码。想怎么加工都可以。

2,722

社区成员

发帖
与我相关
我的任务
社区描述
VFP,是Microsoft公司推出的数据库开发软件,用它来开发数据库,既简单又方便。
社区管理员
  • VFP社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧