當前位置:編程學習大全網 - 源碼下載 - 用vb讀取壹個html文件,去掉標簽只顯示其中文本內容

用vb讀取壹個html文件,去掉標簽只顯示其中文本內容

用webbrower控件

請看下例

’聲明:該程序由csdn論壇獲得

dim dwinfolder as new shellwindows

dim withevents eventie as webbrowser_v1

private sub command1_click()

dim objie as object

for each objie in dwinfolder

if objie.locationurl = list1.list(list1.listindex) then

set eventie = objie

command1.enabled = false

list1.enabled = false

text1.text = ""

exit for

end if

next

end sub

private sub eventie_navigatecomplete(byval url as string)

text1.text = text1.text + chr(13) + chr(10) + url

end sub

在運行前。點擊菜單 projects | references 項,在available references 列表中選擇microsoft internet controls項將internet對象引用介入到工程中

private sub form_load()

dim objie as object

for each objie in dwinfolder

if instr(1, objie.fullname, "iexplore.exe", vbtextcompare) <> 0 then

list1.additem objie.locationurl

end if

next

command1.caption = "正文"

end sub

private sub form_unload(cancel as integer)

set dwinfolder = nothing

end sub

private sub list1_click()

dim objdoc as object

dim objie as object

for each objie in dwinfolder

if objie.locationurl = list1.list(list1.listindex) then

set objdoc = objie.document

for i = 1 to objdoc.all.length - 1

if objdoc.all(i).tagname = "body" then

text1.text = objdoc.all(i).innertext

end if

next

exit for

end if

next

end sub

  • 上一篇:請問Linux與嵌入式Linux區別是什麽?謝謝
  • 下一篇:高強度文件夾加密大師加密的文件解密時老是出現重新加密的狀態?
  • copyright 2024編程學習大全網