教程中国
PHOTOSHOP CS9.0中文版 MAYA 8.5 FOR WINDOWS Corel Painter v9.0 Flash MX2004 中文版 Illustrator cs2 中文版
VC++6.0含sp6 中英文版 VB6.0 +sp6 简体中文版 Borland Delphi 7汉化版 MSDN for vb6.0中文版 Visual Studio 2005简体
教程中国下属 文件存储共享专家BIBIDU.COM 提供大型软件,教材,源码,电影,音乐,图书等下载 更多精品请点此进入
  您目前所在位置: 教程中国 >> VB >> 编程实例 >> 用Webbrowser控件MSHTMLCtl清除广告 RSS订阅
用Webbrowser控件MSHTMLCtl清除广告
用Webbrowser控件MSHTMLCtl清除广告(1)
教程(视频,书籍)下载:  ASP.NET AutoCAD 数据库 C# ASP java photoshop 网页设计 delphi 3dmax Flash C++ VB 张孝祥 实例   更多请进入BIBIDU搜索
IT搜索引擎   

建立一个模块,引用MSHTMLCtl

Option Explicit

Public Function FindADTitle(ByVal vTitle As String) As Boolean
    Dim S As String
    If Not p_bFilterAD Then Exit Function
    S = LCase(vTitle)
    If InStr(1, S, "ad") > 0 Then FindADTitle = True
    If InStr(1, S, "公告") > 0 Then FindADTitle = True
    If InStr(1, S, "about") > 0 Then FindADTitle = True
    If InStr(1, S, "看后吧") > 0 Then FindADTitle = True
    If InStr(1, S, "广告") > 0 Then FindADTitle = True
End Function

'过滤具有广告特征的链接
Public Function FindADURL(ByVal vURL As String) As Boolean
    Dim S As String, F As String, S1() As String
    Dim Hi As Long, Low As Long, N As Long, V As Variant
    If Not p_bFilterAD Then Exit Function
    S = LCase(vURL)
    '特征字符串
    F = "/ad,/ebay/,banner,pop,button,richang,/mall/,move"
    S1 = Split(F, ",")
    Hi = UBound(S1)
    Low = LBound(S1)
    For N = Low To Hi
        If InStr(1, S, S1(N)) > 0 Then
            FindADURL = True
            Exit For
        End If
    Next N
End Function

'请除漂浮广告和GIF动画


Public Sub CleanFlyingANDGifAD(vDoc As HTMLDocument)
    Dim S1 As String
    Dim Item As Object, S As String
    If Not p_bFilterAD Then Exit Sub
    On Error GoTo ERRORHANDL
    If vDoc Is Nothing Then Exit Sub
    For Each Item In vDoc.images
        S = Item.src
        If FindADURL(S) = True Then
            Item.Style.visibility = "hidden"
            Item.Style.Height = 0
            Item.Style.Width = 0
        End If
        If (Item.Style.Position = "absolute") Then
            Item.Style.visibility = "hidden"
            Item.Style.Height = 0
            Item.Style.Width = 0
        End If
    Next Item
    Set Item = Nothing
Exit Sub
ERRORHANDL:
    Resume Next
End Sub

'===================================================

'清除flash动画
'====================================================
Public Sub CleanFlash(vDoc As HTMLDocument)
    Dim Items As IHTMLElementCollection
    Dim Item As Object
    If Not p_bFilterAD Then Exit Sub
    On Error GoTo ERRORHANDL
    Set Items = vDoc.All.tags("OBJECT")
    If Items Is Nothing Then Exit Sub
10:
    For Each Item In Items
        If Not (Item Is Nothing) Then
            If UCase(Item.classid) = "CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000" Then
                Item.Style.visibility = "hidden"
                Item.Style.Height = 0
                Item.Style.Width = 0
            End If
        End If
    Next Item
    Set Items = Nothing
    Set Item = Nothing
    CleanFlashA vDoc
Exit Sub
ERRORHANDL:
    GoTo 10
End Sub

Public Sub CleanFlashA(vDoc As HTMLDocument)
    Dim Items As IHTMLElementCollection
    Dim Item As Object
    If Not p_bFilterAD Then Exit Sub

来源:www.upschool.com.cn
作者:未知
关键字:VB,清除广告,广告拦截,Webbrowser,MSHTMLCtl
发表日期:2007-2-9 16:28:42

网页显示有限 阅读全文请下载本文完整版WORD文档

上一篇:VB 获取系统26项配置信息   下一篇:VB 将域名转换成IP地址


共2页 9 7 [1] [28 :>

本文的相类似文章
  • VB读出一个进程中所有的模块名和模块路径
  • 用VB创建开始菜单快捷方式(无需其他DLL)
  • VB 将域名转换成IP地址
  • 用Webbrowser控件MSHTMLCtl清除广告
  • VB 获取系统26项配置信息
  • VB UTF-8编码转换
  • VB 打开记录集的参数
  • VB断开网络连接!API源码
  • VB 读取收藏夹里的URL地址
  • VB 修改分辨率(不用重启)
  • 网友评论 查看本文全部评论
    笔 名: *
    评 论:
    最多500字。当前字数:0
    联系方式:
    验证码:
    在学习中进步 在进步中成长 教程中国相随您的成长之路
    华腾联合科技股份有限公司版权所有
    广告联系:Rosibo@163.com