Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '~ On Error Resume Next
- Set ARGS = WScript.Arguments
- If ARGS.Count < 2 Then
- WScript.Echo "Usage: cscript //Nologo scripts\foo_allmusic.vbs ""%album artist%"" ""%album%"""
- WScript.Quit()
- Else
- ARTIST = ARGS.Item(0)
- ALBUM = ARGS.Item(1)
- URL = "http://allmusic.com/search/album/" & LCase(Replace(ALBUM, " ", "+"))
- Set RE = New RegExp
- RE.Pattern = "title=""100%""[\s\S]*?<td><a href=""(\S+)""[\s\S]*?<td>([\S ]+)</td>"
- RE.Global = True
- Set Matches = RE.Execute(Request(URL))
- If Matches.Count > 0 Then
- For Each match in Matches
- If match.SubMatches.Count > 1 Then
- If LCase(match.SubMatches(1)) = LCase(ARTIST) Then
- URL = match.SubMatches(0) & "/review"
- Raw = Request(URL)
- Set REr = New RegExp
- REr.Pattern = "<div id=""review"">[\s\S]*?author"">([\S ]+)</p>[\s\S]*?text"">([\s\S ]+?)</p>"
- If REr.Test(Raw) = True Then
- Set R = REr.Execute(Raw)
- WScript.Echo RemTag(R(0).SubMatches(1)) & vbCrLf & vbCrLf & "Review " & R(0).SubMatches(0)
- Set R = Nothing
- Else
- Crawl = 1
- End If
- Set REr = Nothing
- If Not Crawl = 1 Then
- Exit For
- End If
- End If
- End If
- Next
- Else
- WScript.Echo "No Matches for: """ & ALBUM & """ by " & ARTIST
- End If
- Set Matches = Nothing
- Set RE = Nothing
- End If
- Set ARGS = Nothing
- Function Request(URL)
- Set HTTP = CreateObject("MSXML2.ServerXMLHTTP")
- HTTP.open "GET", URL, False
- HTTP.setRequestHeader "User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3"
- HTTP.send ""
- If Err.number <> 0 then
- WScript.Echo "Error: " & HTTP.parseError.URL & vbCrLf & HTTP.parseError.Reason
- End If
- Request = HTTP.responseText
- Set HTTP = Nothing
- End Function
- Function RemTag(strText)
- Set REt = New RegExp
- REt.Pattern = "<[^>]*>"
- REt.Global = True
- RemTag = REt.Replace(strText, "")
- Set REt = Nothing
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement