如何从网页源代码中只提取扩展名为.swf 的链接?
How to extract only links finished by extensions .swf from the source code of a web page?
我想知道如何从网页的源代码中只提取扩展名为 .swf 的链接并将它们保存在文本文件中以便在之后下载它们?
所以我只有这段代码:
$ie = new-object -ComObject InternetExplorer.Application
$ie.Navigate2('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
while($ie.Busy){}
$ie.Document.links|select href
可能是这样的
$ie.Document.body.innerHTML |out-file c:\temp\source.html
$source =gc C:\temp\source.html
($source |Select-String "(\<(.)*\.swf)" -AllMatches)[3]
$wc = New-Object net.webclient
$data = $wc.DownloadString('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
$rx = [regex]::Escape("com.mtvnet.games.GameSettings.Game.metadata.gameURL") + '\s*=\s*[\x27\x22]([^?]+)'
$link = [regex]::Match($data,$rx).groups[1].value
$link
我想知道如何从网页的源代码中只提取扩展名为 .swf 的链接并将它们保存在文本文件中以便在之后下载它们?
所以我只有这段代码:
$ie = new-object -ComObject InternetExplorer.Application
$ie.Navigate2('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
while($ie.Busy){}
$ie.Document.links|select href
可能是这样的
$ie.Document.body.innerHTML |out-file c:\temp\source.html
$source =gc C:\temp\source.html
($source |Select-String "(\<(.)*\.swf)" -AllMatches)[3]
$wc = New-Object net.webclient
$data = $wc.DownloadString('http://www.addictinggames.com/car-games/moto-x3m-game.jsp')
$rx = [regex]::Escape("com.mtvnet.games.GameSettings.Game.metadata.gameURL") + '\s*=\s*[\x27\x22]([^?]+)'
$link = [regex]::Match($data,$rx).groups[1].value
$link