取得网页中特定的链接
private sub command1_click()
webbrowser1.navigate "http://www.95557.com/svote.htm"
end sub
private sub webbrowser1_navigatecomplete2(byval pdisp as object, url as variant)
dim a
for each a in webbrowser1.document.all
if a.tagname = "a" then
if a.href = "http://tech.sina.com.cn/mobile/capture.shtml" then
a.click
end if
end if
next
end sub
option explicit
private m_bdone as boolean
private sub command1_click()
if m_bdone then
dim doc as ihtmldocument2
set doc = webbrowser1.document
dim alink as htmllinkelement
set alink = doc.links(0)
alink.click
end if
end sub
private sub form_load()
webbrowser1.navigate "http://www.95557.com/svote.htm"
end sub
private sub webbrowser1_documentcomplete(byval pdisp as object, url as variant)
m_bdone = true
end sub
==================================================
the following code can be used to query and delete files in the internet cache (including cookies). a demonstration routine can be found at the bottom of this post. note, the enumerated type ecachetype is not supported in excel 97, but can be changed to a list of public constants eg. public const enormal = &h1&.
option explicit
'--------------------------types, consts and structures
private const error_cache_find_fail as long = 0
private const error_cache_find_success as long = 1
private const error_file_not_found as long = 2
private const error_access_denied as long = 5
private const error_insufficient_buffer as long = 122
private const max_cache_entry_info_size as long = 4096
private const lmem_fixed as long = &h0
private const lmem_zeroinit as long = &h40
public enum ecachetype
enormal = &h1&
eedited = &h8&
etrackoffline = &h10&
etrackonline = &h20&
esticky = &h40&
esparse = &h10000
ecookie = &h100000
eurlhistory = &h200000
eurlfinddefaultfilter = 0&
end enum
private type filetime
dwlowdatetime as long
dwhighdatetime as long
end type
private type internet_cache_entry_info
dwstructsize as long
lpszsourceurlname as long
lpszlocalfilename as long
cacheentrytype as long 'type of entry returned
dwusecount as long
dwhitrate as long
dwsizelow as long
dwsizehigh as long
lastmodifiedtime as filetime
expiretime as filetime
lastaccesstime as filetime
lastsynctime as filetime
lpheaderinfo as long
dwheaderinfosize as long
lpszfileextension as long
dwexemptdelta as long
end type
'--------------------------internet cache api
private declare function findfirsturlcacheentry lib "wininet.dll" alias "findfirsturlcacheentrya" (byval lpszurlsearchpattern as string, lpfirstcacheentryinfo as any, lpdwfirstcacheentryinfobuffersize as long) as long
private declare function findnexturlcacheentry lib "wininet.dll" alias "findnexturlcacheentrya" (byval henumhandle as long, lpnextcacheentryinfo as any, lpdwnextcacheentryinfobuffersize as long) as long
private declare function findcloseurlcache lib "wininet.dll" (byval henumhandle as long) as long
private declare function deleteurlcacheentry lib "wininet.dll" alias "deleteurlcacheentrya" (byval lpszurlname as string) as long
'--------------------------memory api
private declare function localalloc lib "kernel32" (byval uflags as long, byval ubytes as long) as long
private declare function localfree lib "kernel32" (byval hmem as long) as long
private declare sub copymemory lib "kernel32" alias "rtlmovememory" (pdest as any, psource as any, byval dwlength as long)
private declare function lstrcpya lib "kernel32" (byval retval as string, byval ptr as long) as long
private declare function lstrlena lib "kernel32" (byval ptr as any) as long
'purpose : deletes the specified internet cache file