首页 文章

Visual Basic - 从SourceCode获取URL列表

提问于
浏览
0

我一直致力于一个程序,使我能够监控我的哪些公司客户链接到我们的网站 . 如果我可以使它工作,将节省大量时间浪费在手动搜索客户端网站 .

目前我有一个存储所有客户主页URL的数据库 . 我的程序循环遍历这些URL,抓取他们的SourceCode并将SourceCode放入文本框中 . 然后,它会在文本框中搜索我的公司URL,并返回“True”或“False”值 .

如果为'True'则链接存在,但如果'False',我需要我的程序搜索同一站点上的其他页面,并检查链接是否存在于其他任何地方 .

To do this I need my program to cycle through the SourceCode(in textbox already) and find all other URLs that link to other pages on the same site (e.g www.example.com, www.example.com/contact-us, www.example.com/about) and store them in a list. Im not sure how to do this?

1 回答

  • 0

    基于......的解决方案怎么样?

    Regex Help: Get list of URL(s) except extention .css, .js, .jpg, .gif, .png

    Dim MyRegex As New Regex("href=""(?<URL>(?:(?!javascript)(?!#))[a-zA-Z0-9\~\!\@\#\$" + "\%\^\&amp;\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]+)" + "(?<!(?:\.png|\.js|\.jpg|\.jpeg|\.css|\.gif|\.zip|\.r" + "ar))""(?:$|>|\s)", RegexOptions.Multiline Or RegexOptions.CultureInvariant Or RegexOptions.Compiled)
    
                Dim matches As MatchCollection = MyRegex.Matches(textbox1.text)
                For Each item In matches
                    ListBox1.Items.Add(item.ToString())
    
                Next
    

    那你需要过滤掉不相关的网站吗?

相关问题