導航:首頁 > 源碼編譯 > 腳本獲取源碼指定的鏈接

腳本獲取源碼指定的鏈接

發布時間:2022-09-21 16:21:45

⑴ vba 中怎麼通過鏈接獲取網頁源碼

兩種方法,一是使用AJAX,二是開啟IE進程,我推薦用方法一,我的例子代碼如下:

Dimhttp
Sethttp=CreateObject("Microsoft.XMLHTTP")
http.Open"POST","連接地址",False
http.send""
Ifhttp.Status=200Then
selection.text=http.responseText
EndIf

⑵ 如何提取網頁源代碼中的鏈接代碼

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

⑶ 腳本大師做的腳本怎麼導出源碼

法導出源碼的。如果不是小精靈好辦了,按鍵精靈的腳本一般都是用文本文件編寫的,直接打開腳本文本,復制裡面的內容就行,但是一旦製作成按鍵小精靈,你就沒辦法從裡面獲取腳本源碼,只能用錄制功能再錄制一遍,但錄制出來的內容只是前台的滑鼠操作和鍵盤操作,像找怪、自動加血這些功能是沒有辦法錄制的。

⑷ 怎麼從html源碼中獲取URL鏈接

1、火狐瀏覽器 點到一個空白的頁面 右鍵 查看源代碼 裡面有url的一些地址;

希望對你有所幫助!!

⑸ "如何用shell腳本獲取網頁源碼"

shell調用可抓取網頁的工具即可。可寫好抓取的python腳本,再用shell調用就行

⑹ 如何提取出網頁源碼裡面的超鏈接地址

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

⑺ VBS里從網頁源碼里提取需要的網頁鏈接

dim xp,url,MyStream
url=inputbox("輸入網址")
if url&"a"<>"a" then
set xhp=createobject("microsoft.xmlhttp")
xhp.open "get",url,false
xhp.send
Set MyStream=CreateObject("Adodb.Stream")
MyStream.Type = 1
MyStream.Open
MyStream.Write xhp.responseBody
MyStream.SaveToFile "c:\xxx.html"
Msgbox "保存成功!哈哈"
end if

⑻ 怎麼從html源碼中獲取URL鏈接

從html源碼中獲取URL鏈接的方法是寫正則表達式處理。
舉例:PHP獲取頁面中的所有鏈接
function getPageLink($url){
// 獲取源文件的內容
$html=file_get_contents($url);
//編寫正則表達式,匹配所有a標簽內部的http連接
preg_match_all("/<a(s*[^>]+s*)href=([\"|']?)([^\"'>\s]+)([\"|']?)/ies",$html,$out);
// 匹配到的鏈接存入數組out

$arrLink=$out[3];
//解析鏈接
$arrUrl=parse_url($url);
// 返回鏈接
return $arrUrl;
}

⑼ Shell腳本中如何獲取軟鏈接的地址

$(pwd)和`pwd`效果是一樣的,返回的是當前的路徑

${0}返回的是腳本與當前路徑的相對路徑

所以

echo $(pwd)/${0}
就是腳本的絕對路徑了

你執行下這個腳本就明白了

#!/bin/bash -x
echo ${0}
echo $(pwd)
echo $(pwd)/${0}

⑽ 誰會寫個VBS腳本批量獲取URL地址源代碼內容

Dimfso,ts,s
setWshShell=WScript.CreateObject("WScript.Shell")
Setfso=CreateObject("Scripting.FileSystemObject")
Setts=fso.OpenTextFile("D:url.txt",1)'url.txt放在D盤
DoUntilts.AtEndOfStream
s=ts.ReadLine
iflen(s)>1then'非空行
'msgboxs
url_tmp=Trim(s)'去兩端空格
'msgboxurl_tmp
date_str=get_url(url_tmp)
'msgboxdate_str
export_strurl_tmp&""&date_str&chr(13)&chr(10)
endif
loop
ts.Close
setWshShell=nothing
setfso=nothing
setts=nothing
msgbox"運行結束!"

Functionget_url(url)
Dimhttp
url_str="http://"&url&"/1.txt"'http://www.xx.com/1.txt
Sethttp=CreateObject("Msxml2.ServerXMLHTTP")
http.open"GET",url_str,False
http.send
ifhttp.status<>200then
get_url="error"'獲取失敗
else
get_url=http.responseText
endif
Sethttp=nothing
EndFunction

Subexport_str(str_e)
dimfs,exp_File
setfs=createobject("scripting.filesystemobject")
Setexp_File=fs.opentextfile("d:url_date.txt",8,true)'結果也在D盤
exp_File.writestr_e
exp_File.close
setfs=nothing
Setexp_File=nothing
EndSub

閱讀全文

與腳本獲取源碼指定的鏈接相關的資料

熱點內容
日語命令性 瀏覽:259
免費的程序編譯游戲 瀏覽:889
如何安裝屏蔽的APP 瀏覽:196
豬臉識別app如何下載 瀏覽:154
卓嵐串口伺服器如何使用 瀏覽:438
pdf周振甫 瀏覽:756
程序員35歲生日圖片 瀏覽:626
矩形密封圈的壓縮量 瀏覽:455
信息安全中圖像加密技術畢業論文 瀏覽:536
gear2刷android 瀏覽:79
怎麼用安卓下載櫻校 瀏覽:580
現在什麼app可以賺錢 瀏覽:155
基礎梁鋼筋圖紙未標注加密區間距 瀏覽:469
通達信指標源碼公式半透明 瀏覽:956
開發什麼手機app好 瀏覽:320
csgo如何在游戲里進入完美伺服器 瀏覽:190
編程教育老師成長心態 瀏覽:257
音頻採集單片機 瀏覽:590
加密管的優點 瀏覽:280
dock基礎命令 瀏覽:345