用正则提取chrome生成书签的链接
会把chrome生成的书签html文件中的链接标题提取出来,生成txt文件,这样自己的收藏的网址要在网上发帖什么的就方便多了,链接标题中我是用tab键隔开方便复制到excel
a标签 = <A.HREF="[a-zA-z]+://[^\s]*"[^>]*>([^<]*)</A>
标题 =<A.HREF="[^>]*>([^<]*)</A>
链接 =<A.HREF="([a-zA-z]+://[^\s]*)"
FileSelectFile, OutputVar1 ,,,, *.html
if OutputVar1 =
{
MsgBox 未选文件
return
}
FileRead, OutputVar, %OutputVar1%
SplitPath,OutputVar1, OutFileName, OutDir, OutExtension, OutNameNoExt, OutDrive
SubPat := RegExMatchAll(OutputVar, a标签)
loop % SubPat.Length()
{
提取 := SubPat[A_Index ]
a标题 := RegExMatchAll(提取, 标题,1)
a链接 := RegExMatchAll(提取, 链接,1)
ahebin := a标题[1] . A_Tab . a链接[1] "`n"
hebin .= ahebin
}
File := OutDir . "\" . OutNameNoExt . ".txt"
;MsgBox % hebin
FileAppend , %hebin%, %File%
RegExMatchAll(ByRef Haystack, NeedleRegEx, SubPat="") {
arr := [], startPos := 1
while ( pos := RegExMatch(Haystack, NeedleRegEx, match, startPos) ) {
arr.push(match%SubPat%)
startPos := pos + StrLen(match)
}
return arr.MaxIndex() ? arr : ""
}
ExitApp
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


赞