RegEx匹配网站

时间:2015-07-29 05:52:08

标签: regex powershell-v3.0

我目前有以下脚本:

$ie = New-Object -comObject InternetExplorer.Application
$ie.navigate('http://www.hotnewhiphop.com/top100')
$null = $ie.Document.body.innerhtml -match '<em\sclass="chartItem-bubble-rank">1</em>(.|\n)*<a\stitle="(.*)"\sclass="chartItem';$hotnewhiphop1song = $matches[2];$hotnewhiphoptop100 += $hotnewhiphop1song
$null = $ie.Document.body.innerhtml -match '<em\sclass="chartItem-bubble-rank">2</em>(.|\n)*<a\stitle="(.*)"\sclass="chartItem';$hotnewhiphop2song = $matches[2];$hotnewhiphoptop100 += $hotnewhiphop2song
$null = $ie.Document.body.innerhtml -match '<em\sclass="chartItem-bubble-rank">3</em>(.|\n)*<a\stitle="(.*)"\sclass="chartItem';$hotnewhiphop3song = $matches[2];$hotnewhiphoptop100 += $hotnewhiphop3song
$null = $ie.Document.body.innerhtml -match '<em\sclass="chartItem-bubble-rank">4</em>(.|\n)*<a\stitle="(.*)"\sclass="chartItem';$hotnewhiphop4song = $matches[2];$hotnewhiphoptop100 += $hotnewhiphop4song

以上只是剧本的4个部分,网站的歌曲编号为1-4。最初在网站上有20首歌曲,但总共有100首歌曲。首先,我使用的RegEx并不匹配确切的歌曲,它找到了最后一场比赛,我想我需要以某种方式让这种非贪婪,但可能是错误的。

歌曲编号以 chartItem-bubble-rank

的值列出

另一件事是,当导航到网站本身时,最初只有20首歌曲,但是当我们向下滚动时,鼠标会开始出现更多歌曲,我想要捕捉的总共有100首歌曲全部变量 $ hotnewhiphoptop100

0 个答案:

没有答案