请教一个分析网页字符串的问题!!谢谢

koktiger 2009-03-29 04:04:05
大家好,本人学VB 不久,纯业余爱好.
现在自学到字符串分析,请大家帮忙看看下面的代码哪里错了
运行时的错误提示已经标出.
谢谢!
对于处理的网址为随意查找,并无任何想法,请相关站长谅解.


htmlstr = Inet1.OpenURL("http://www.upkav.cn/kav/kabasijishadu-soft/", icString)

Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim m As Integer


Dim istr As String

'---获取真实key地址---
n = InStr(htmlstr, "<!--正文-->")
i = InStr(n, htmlstr, "<a href=")

j = InStr(i, htmlstr, ">")

istr = Mid(htmlstr, i + 9, j - i - 9)



htmlstr = Inet1.OpenURL(istr) '以下4行容易出错

n = InStr(htmlstr, "<!--正文-->")


m = InStr(n, htmlstr, "<script")


i = InStr(m, htmlstr, "<table cell")
j = InStr(i, htmlstr, "</table>")

htmlstr = Mid(htmlstr, i, j + 8 - i)


上面代码的用意是 在初始网址中找到特定的网址(因为有用的内容在这个链接的网址上),然后把这个链接传递给inet控件下载源文件,然后进行分析.出错位置,自己分析可能是变量为"0"导致,但是反复分析网页源码,确实存在对应字符串.不得其解.
请各位帮忙!!
...全文
51 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
koktiger 2009-03-29
  • 打赏
  • 举报
回复
谢谢大哥提醒...会注意的!!
等调试成功就结贴!!
HtSoft 2009-03-29
  • 打赏
  • 举报
回复
请学会使用调试功能,注意空格,加上错误处理代码


Dim htmlstr As String
htmlstr = Inet1.OpenURL("http://www.upkav.cn/kav/kabasijishadu-soft/")

Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim m As Integer


Dim istr As String

'---获取真实key地址---
n = InStr(htmlstr, "<!--正文-->")
i = InStr(n, htmlstr, "<a href=")

j = InStr(i, htmlstr, ">")

istr = Mid(htmlstr, i + 9, j - i - 9 - 1)
Debug.Print istr

htmlstr = Inet1.OpenURL(istr)

n = InStr(htmlstr, "<!--正文-->")


m = InStr(n, htmlstr, "<script")


i = InStr(m, htmlstr, "<table cell")
j = InStr(i, htmlstr, "</table>")

htmlstr = Mid(htmlstr, i, j + 8 - i)

Debug.Print htmlstr

1,502

社区成员

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

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