网页取源码
Private Sub Command1_Click()
Dim s As String
s = Text1.Text
s = Replace(Text1.Text, vbCrLf, "") '移除所有回车换行符
'Dim oRegEx As RegExp
'Set oRegEx = New RegExp
'Dim oMatches As MatchCollection
'Dim oMatch As Match
Dim oRegEx As Object
Set oRegEx = CreateObject("VBScript.RegExp")
Dim oMatches As Object
Dim oMatch As Object
With oRegEx
.Global = True '全局匹配
.IgnoreCase = True '忽略大小写
.Pattern = "<a[^>]*?href=[""' ]?(.*?)(?:""|'| ).[^> ]*?>([\s\S]*?)</a>"
'提取所有A标签的正则式,小括号中是子匹配引用组第一个是 (.*?) 第二个是([\s\S]*?)
Set oMatches = .Execute(s)
If oMatches.Count >= 1 Then
Text2.Text = ""
Dim sHref As String, sInnerText As String
Dim i As Integer
Dim sLink As String
'Dim colLinks As Scripting.Dictionary
'Set colLinks = New Scripting.Dictionary
Dim colLinks As Object
Set colLinks = CreateObject("Scripting.Dictionary")
For Each oMatch In oMatches
sHref = oMatch.SubMatches(0) '(.*?)
sInnerText = oMatch.SubMatches(1) '([\s\S]*?)
sInnerText = RemoveTags(sInnerText) '移除A标签(内容)中的多余标签
sInnerText = Replace(sInnerText, " ", "") '移除A标签(内容)中的所有空格
sLink = "<A href=""" & sHref & """>" & sInnerText & "</A>"
If Not colLinks.Exists(sLink) Then
colLinks.Add sLink, sLink
Text2.Text = Text2.Text & sLink & vbNewLine
End If
Next
End If
End With
Set oMatches = Nothing
Set oMatch = Nothing
Set oRegEx = Nothing
Set colLinks = Nothing
End Sub
'这个函数可以去除html代码中的标签
Function RemoveTags(ByVal html As String)
'Dim oRegEx As RegExp
'Set oRegEx = New RegExp
Dim oRegEx As Object
Set oRegEx = CreateObject("VBScript.RegExp")
With oRegEx
.Global = True
.IgnoreCase = True
.Pattern = "<[^>]*>"
RemoveTags = .Replace(html, "")
End With
Set oRegEx = Nothing
End Function
⑵ 求一在一大段网页源代码中提取URL源码
呵呵,我以前写过一个函数,你试试吧:
Private Sub Command1_Click()
Text1 = FindStrMulti$(源码变量, "WWW", "COM", vbCrLf, 1)
End Sub
'取得字符串中的指定内容(字符串变量,关键字前缀,关键字后缀,输出的分隔符,是否包含关键字)
Function FindStrMulti$(Strall$, FirstStr$, EndStr$, SplitStr$, Findmod&)
Dim i&, j&
Do
i = InStr(i + 1, Strall, FirstStr)
If i = 0 Then Exit Do
If Findmod = 0 Then i = i + Len(FirstStr)
j = InStr(i, Strall, EndStr)
If j = 0 Then Exit Do
If Findmod = 1 Then j = j + Len(EndStr)
FindStrMulti = IIf(Len(FindStrMulti) > 0, FindStrMulti & SplitStr, "") & Mid(Strall, i, j - i)
Loop
End Function
⑶ 如何通过网页源代码来提取网页中的图片
可以现在网页源码中找到图片的链接,然后将图片在新窗口打开并进行保存。
1、右版击想要提取的图片权,在展开的菜单中点击“检查”按钮打开控制台:
⑷ 怎么获取网页源代码中的文件
获取网页源代码中的文件的具体步骤如下:
1、首先我们在浏览器里随意打开一张网页查看版其源代码。权
⑸ 如何获取html网页原始的源代码
直接打开网页,快捷键 Ctrl + U ,看到的就是源代码
⑹ 如何获得某个网页的PHP源码
那你只能跟网站的拥有者或者开发者联系索取了。别妄想直接通过某个软件或程序就能获得网站的后台源码,要真能这样,我把支付宝的源码拿来玩玩?
当然,如果你能找到一个牛X的黑客通过非常规的手段去获取源码,那当我没说。
⑺ 请问如何提取网页源代码指定内容(最好用批处理)
就是一个采集工具了。建议安装个采集软件试下,破解版的火车头
⑻ 怎样取得网页中的HTML源代码
1、浏览器打开网页,右键-》查看源代码
以上两种方法,选择其一即可。
⑼ 怎样得到一个网页的源代码
右击网页,点击“查看源代码”;或是在浏览器菜单中选择“查看”->“查看网页源代码”。