有没有比inet控件更快得到网页源文件的方法?

assa 2003-11-19 02:52:42
请问有没有比inet控件更快得到网页源文件的方法:

dim content as string
Inet1.url="www.sohu.com"
content = Inet1.OpenURL(Inet1.url)
msgbox content

请各位指点
感谢感谢~
...全文
34 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
assa 2003-11-24
  • 打赏
  • 举报
回复
up
assa 2003-11-23
  • 打赏
  • 举报
回复
我看了一段代码是这样的
IStream * pStream;
URLOpenStream (NULL, L"http://www.msn.com/", &pStream,
0, 0);

char buffer[0x100];

DWORD dwGot;
HRESULT hr = NOERROR;

do {
hr = pStream->Read (buffer, sizeof(buffer),&dwGot);

//.. do something with contents of buffer ...
} while (SUCCEEDED(hr));
.
可是明明URLOpenStream没有定义什么数据输出接口呀
msdn 上是这么定义的

HRESULT URLOpenStream(
LPUNKNOWN pCaller,
LPCSTR szURL,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB
)
哪位高手能解释解释如何得到内容,难道也要做个地址指针来循环吗?
assa 2003-11-22
  • 打赏
  • 举报
回复
不懂不懂,看的有点晕了!!!!

Private Declare Function URLOpenStream Lib "urlmon" _
Alias "URLOpenStreamA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal content As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long


Private Sub Command1_Click()
Dim content As Variant
URLOpenStream 0, "http://www.sohu.com", content, 0, 0
MsgBox content
End Sub

无法实现!为什么不能直接给content值呢??
hhjjhjhj 2003-11-22
  • 打赏
  • 举报
回复
URLDownloadToFile 0, "http://www.sohu.com", "c:\test.txt", 0, 0
URLOpenStream如何使用-----看API资料或微软MSDN网站
assa 2003-11-22
  • 打赏
  • 举报
回复
to: hhjjhjhj(大头)

URLDownloadToFile 0, "www.sohu.com", "c:\test.txt", 0, 0

程序没报错,但是找不到test.txt文件,为什么??
assa 2003-11-22
  • 打赏
  • 举报
回复
请问URLOpenStream如何使用,能说详细点吗?谢谢!
hhjjhjhj 2003-11-21
  • 打赏
  • 举报
回复
其实webbrowser1最慢.它要把所有图片下载完了才行,如果碰到一个图片来自另一个服务器,并且打不开,那你就等着吧!不过它是异步执行的,所以不影响程序的运行.
其实还有更快的------URLOpenStream(类似URLDownloadToFile)
hhjjhjhj 2003-11-21
  • 打赏
  • 举报
回复
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Sub Command1_Click()
URLDownloadToFile 0, "http://office.9zp.com/index.asp", "c:\test.txt", 0, 0
End Sub
online 2003-11-21
  • 打赏
  • 举报
回复
webbrowser1要加载网页
将timer1时间调短一些
captainivy 2003-11-21
  • 打赏
  • 举报
回复
我觉得应该没有了

关注一下
assa 2003-11-21
  • 打赏
  • 举报
回复

我测试过了,的确webbrowser快,可是要立刻得到源代码好像就慢了些
为什么半天都得不到内容呢?text1.text=objhtml.htmltext
感谢
online 2003-11-19
  • 打赏
  • 举报
回复
试试这个
加入timer,commandbutton,text
private sub command1_click()
webbrowser1.navigate http://www.sohu.com/
timer1.enabled=true
end sub

private sub timer1_timer()
dim doc,objhtml as object
dim i as integer
dim strhtml as string

if not webbrowser1.busy then
set doc=webbrowser1.document
i=0
set objhtml=doc.body.createtextrange()
if not isnull(objhtml) then
text1.text=objhtml.htmltext
end if
timer1.enabled=false
end if
end sub
assa 2003-11-19
  • 打赏
  • 举报
回复
请问有没有比inet控件更快得到网页源文件的方法:

dim content as string
Inet1.url="www.sohu.com"
content = Inet1.OpenURL(Inet1.url)
msgbox content

请各位指点
感谢感谢~

7,732

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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