Vbscript 读取文件夹/文件名,在internet上搜索并自动保存相关图片
根据,哪些州?Vbscript 读取文件夹/文件名,在internet上搜索并自动保存相关图片,vbscript,scripting,automation,Vbscript,Scripting,Automation,根据,哪些州? 如果你有一个你已经知道答案的问题 如果您想公开记录,以便其他人(包括您自己)稍后可以找到它 您可以在相关的Stack Exchange站点上提问并回答自己的问题 说得非常清楚,不仅可以问和回答您自己的问题,而且明确鼓励您这样做 我把它放在这里是为了研究,但是如果有人愿意将它转换成JavaScript(可能是node.js?),那将非常感谢 我的SendTo文件夹中有这个VBScript,因此我可以单击任何电影文件夹或文件,在和上搜索它,并自动将电影海报另存为文件夹.jpg
- 如果你有一个你已经知道答案的问题
- 如果您想公开记录,以便其他人(包括您自己)稍后可以找到它
- 您可以在相关的Stack Exchange站点上提问并回答自己的问题
node.js
?),那将非常感谢
我的
SendTo
文件夹中有这个VBScript
,因此我可以单击任何电影文件夹或文件,在和上搜索它,并自动将电影海报另存为文件夹.jpg
享受
PS:使用CScript
快捷方式执行它,否则您将得到大量“警报”(由于WScript.Echo
)为什么(几乎)不必要的解释?因为我之前的尝试被搁置了。原因是什么<代码>这不是问题。所以这不是展示你作品的好地方。为此,请使用博客。Nice…:/
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