根据It’s OK to Ask and Answer Your Own Questions,陈述
- 如果您有一个问题,您已经知道答案
- 如果您想公开记录,以便其他人(包括您自己)可以在以后找到它
- 可以在相关的Stack Exchange网站上询问并回答您自己的问题。
要说清楚,不仅可以提出并回答您自己的问题,而是明确鼓励
我将它放在这里供研究用户使用,但是如果有人愿意将其转换为JavaScript(也许是node.js
?),那将非常感激。
我的VBScript
文件夹中有SendTo
,因此我可以点击任意电影文件夹或文件,然后在IMDB和RotenTomatoes上进行搜索,并自动保存电影海报为folder.jpg
。
享受。
PS:使用CScript
快捷方式执行它,否则您最终会收到很多“提醒”(由于WScript.Echo
)
答案 0 :(得分:0)
Dim objVideo, objRegEx
DebugMode = False
objFile = Wscript.Arguments(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
objVideo = objFSO.GetBaseName(objFile)
ImageFile = "folder.jpg"
VideoYearParenteses = ""
DestFolder = objFSO.GetParentFolderName(objFile) & "\"
If objFSO.FolderExists(objFile) Then DestFolder = objFSO.GetAbsolutePathName(objFile) & "\"
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "((19|20)\d\d)"
Set VideoYearMatches = objRegEx.Execute(objVideo)
If VideoYearMatches.count > 0 Then
VideoYear = Trim(VideoYearMatches.item(0))
VideoYearParenteses = "+(" & VideoYear & ")"
End If
objRegEx.Pattern = "\W?((19|20)\d\d|(720|1080)(i|p)).*"
VideoTitle = objRegEx.Replace(objVideo, "")
VideoTitle = Trim(VideoTitle)
objRegEx.Pattern = "(\s|\.|_)"
VideoTitleEncoded = objRegEx.Replace(VideoTitle, "+")
VideoTitleEncoded = Trim(VideoTitleEncoded)
If DebugMode Then WScript.Echo "Nome original: " & objVideo & vbCrlf & "VideoTitle: " & VideoTitle & vbCrlf & "VideoTitleEncoded: " & VideoTitleEncoded & vbCrlf & "VideoYear: " & VideoYear
' OPEN WITH CHROME? IS THERE A CHROME OBJECT TO MANIPULATE?
Set wshShell = CreateObject("WScript.Shell")
'wshShell.Run "chrome.exe http://www.imdb.com/search/title?title=" & VideoTitleEncoded & "&release_date=" & VideoYear & "&title_type=feature"
'wshShell.Run "chrome.exe http://www.imdb.com/find?s=tt&exact=true&q=" & VideoTitleEncoded & VideoYearParenteses
'wshShell.Run "chrome.exe http://www.rottentomatoes.com/search/?search=" & VideoTitleEncoded & VideoYearParenteses
' INTERNET EXPLORER OBJECT AND DOM MANIPULATION
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate "http://www.imdb.com/search/title?title=" & VideoTitleEncoded & "&release_date=" & VideoYear & "&title_type=feature"
If DebugMode Then ie.Visible = True
Do While ie.Busy
WScript.Sleep 100
Loop
imgThumb = ie.document.getElementById("main").getElementsByTagName("img").item(0).src
WScript.Echo("Caminho da imagem pequena: " & imgThumb)
Call Principal
Sub Principal
Set regEx = New RegExp
With regEx
.Global = True
.IgnoreCase = True
.Pattern = "\._.*(?=\.)"
End With
imgNormal = regEx.Replace(imgThumb, "")
WScript.Echo("Caminho da imagem grande: " & imgNormal)
If DebugMode Then ie.Navigate imgNormal
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", imgNormal, False
xml.Send
Set oStream = createobject("Adodb.Stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
oStream.type = adTypeBinary
oStream.open
oStream.write xml.responseBody
'oStream.savetofile DestFolder & ImageFile, adSaveCreateNotExist
oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
WScript.Echo(vbCrLf & "Imagem salva em " & DestFolder & ImageFile)
oStream.close
set oStream = nothing
Set xml = Nothing
WScript.Echo(vbCrLf & "Fim!")
End Sub