您的位置:程序门 -> vb ->



用api读取网页(文本文件)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


用api读取网页(文本文件)[已结贴,结贴人:frankwong]
发表于:2007-04-17 10:30:50 楼主
有一个网站文件   www.abc.com/1.txt
本来可以通过
msgbox   inet1.openurl( "www.abc.com/1.txt ")
获得,但现在希望通过api实现相同效果,请问如何实现,谢谢!
发表于:2007-04-17 10:44:531楼 得分:0
问题解决:
private       declare       function       internetopen       lib       "wininet.dll "       alias       "internetopena "       (       _      
                                                                                    byval       sagent       as       string,       byval       laccesstype       as       long,       _      
                                                                                    byval       sproxyname       as       string,       byval       sproxybypass       as       string,       _      
                                                                                    byval       lflags       as       long)       as       long      
    private       declare       function       internetopenurl       lib       "wininet.dll "       alias       "internetopenurla "       (       _      
                                                                                    byval       hinternetsession       as       long,       byval       surl       as       string,       _      
                                                                                    byval       sheaders       as       string,       byval       lheaderslength       as       long,       _      
                                                                                    byval       lflags       as       long,       byval       lcontext       as       long)       as       long      
    private       declare       function       internetreadfile       lib       "wininet.dll "       (       _      
                                                                                    byval       hfile       as       long,       byval       sbuffer       as       string,       _      
                                                                                    byval       lnumbytestoread       as       long,       _      
                                                                                    lnumberofbytesread       as       long)       as       integer      
    private       declare       function       internetclosehandle       lib       "wininet.dll "       (       _      
                                                                                    byval       hinet       as       long)       as       integer      
    private       const       internet_flag_no_cache_write       =       &h4000000      
    dim       s      
       
       
       
    private       function       geturlfile(sturl       as       string)       as       string      
                    dim       lginternet       as       long,       lgsession       as       long      
                    dim       stbuf       as       string       *       1024      
                    dim       inres       as       integer      
                    dim       lgret       as       long      
                    dim       sttotal       as       string      
                    sttotal       =       vbnullstring      
                    lgsession       =       internetopen( "vbtagedit ",       1,       vbnullstring,       vbnullstring,       0)      
                    if       lgsession       then      
                                    lginternet       =       internetopenurl(lgsession,       sturl,       vbnullstring,       _      
                                                                                                                                                        0,       internet_flag_no_cache_write,       0)      
                                    if       lginternet       then      
                                                    do      
                                                                    inres       =       internetreadfile(lginternet,       stbuf,       1024,       lgret)      
                                                                    if       (lgret       =       1024)       then      
                                                                                    sttotal       =       sttotal       &       stbuf      
                                                                    else      
                                                                                    sttotal       =       sttotal       &       strconv(leftb$(strconv(stbuf,       vbfromunicode),       lgret),       vbunicode)      
                                                                    end       if      
                                                    loop       while       (lgret       <>       0)      
                                                    '      
                                    end       if      
                                    inres       =       internetclosehandle(lginternet)      
                    end       if      
                    geturlfile       =       sttotal      
    end       function      
       
       
    private       sub       command1_click()      
    debug.print       geturlfile( "http://www.163.com ")      
    end       sub
发表于:2007-04-17 13:16:342楼 得分:15
:)
发表于:2007-04-17 13:23:073楼 得分:3
怎么回事啊,我为何不能发帖子,真奇怪,????我不能进入提问的页面????
发表于:2007-04-17 13:30:054楼 得分:2
怎么回事啊,我为何不能发帖子,真奇怪,????我不能进入提问的页面????


快速检索

最新资讯
热门点击