Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Name: InstaMeta CScript Version 2.0
- ' File: InstaMeta_v2.0.vbs
- ' Licence: N/A
- ' Author: Mark Albanese (Devious_Malcontent)
- ' Date: 3 August 2014
- ' Version: 2.0
- ' Release: 1
- ' Language: VBScript
- ' Compiler: N/A
- ' Notes: This script can only be run from cscript.exe command line. Your Instagram account must also be public.
- ' Default encoding is ANSI, however this can be changed to UTF by opening the file in notepad and saving it as UTF format.
- ' Usage: Save as "InstaMeta_v2.0.vbs"
- ' Run this from command line using cscript.exe, eg: cscript C:\path\to\script\InstaMeta_v2.0.vbs username
- ' Where username is your Instagram username.
- Set objFSO = Createobject("Scripting.FileSystemObject")
- Set objShell = wscript.createobject("wscript.shell")
- Set objStdIn = WScript.StdIn
- Set objStdOut = WScript.StdOut
- If WScript.Arguments.Count = 0 then
- objStdOut.Write "Instagram Username: "
- username = objStdIn.ReadLine
- OutputFileName = username & "_Instagram_Metadata" & Replace(Replace(Replace(FormatDateTime(Now()),"/","."),":",".")," ","_") & ".csv"
- Else
- username = WScript.Arguments(0)
- objStdOut.WriteLine "Instagram Username: " & username
- OutputFileName = username & "_Instagram_Metadata" & Replace(Replace(Replace(FormatDateTime(Now()),"/","."),":",".")," ","_") & ".csv"
- If WScript.Arguments.Count = 2 Then
- OutputFileName = WScript.Arguments(1)
- End if
- End if
- it=1
- strFileURL = "http://www.iphoneogram.com/" & username
- strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
- Dim objFile, strLine, out
- Set out = objFSO.OpenTextFile(objShell.CurrentDirectory & "\" & OutputFileName, 2, True)
- Call getMeta(strFileURL,strHDLocation)
- objFile.Close
- objStdOut.WriteLine "Performing clean up..."
- Do Until it=0
- strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
- If objFSO.Fileexists(strHDLocation) Then
- objFSO.DeleteFile strHDLocation
- objStdOut.WriteLine "Deleting temporary file: " & strHDLocation
- End If
- it=it-1
- Loop
- Set objFSO = Nothing
- objStdOut.WriteLine "Output File Name: " & OutputFileName
- objStdOut.WriteLine "Done!"
- Function ReplacePattern(patrn, replStr, str1)
- Dim regEx
- Set regEx = New RegExp
- regEx.Pattern = patrn
- regEx.IgnoreCase = True
- ReplacePattern = regEx.Replace(str1, replStr)
- End Function
- Sub getMeta(strFileURL,strHDLocation)
- objStdOut.WriteLine "Reading URL: " & strFileURL
- objStdOut.WriteLine "To File: " & strHDLocation
- Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
- objXMLHTTP.open "GET", strFileURL, false
- objXMLHTTP.send()
- If objXMLHTTP.Status = 200 Then
- Set objADOStream = CreateObject("ADODB.Stream")
- objADOStream.Open
- objADOStream.Type = 1
- objADOStream.Write objXMLHTTP.ResponseBody
- objADOStream.Position = 0
- If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
- objADOStream.SaveToFile strHDLocation
- objADOStream.Close
- Set objADOStream = Nothing
- End if
- Set objXMLHTTP = Nothing
- Set objFile = objFSO.OpenTextFile(strHDLocation, 1)
- Dim strSearchFor1, strSearchFor2, strSearchFor3, strSearchFor4, strSearchFor5
- strSearchFor1 = "text com"
- strSearchFor2 = "p-time-block"
- strSearchFor3 = "Original Image"
- strSearchFor4 = "View in Instagram web page"
- strSearchFor5 = "id=""next-link"">More"
- GetNextLine = False
- Do While Not objFile.AtEndOfStream
- strLine = objFile.readline
- If GetNextLine = True Then
- If InStr(1, strLine, "</p>") > 0 then
- GetNextLine = False
- End If
- strLine = Replace(strLine,",",",")
- strLine = Replace(strLine,"</p>"," ")
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write " " & strLine
- objStdOut.WriteLine "Writing Remaining Description"
- End If
- If InStr(1, strLine, strSearchFor1) > 0 then
- If InStr(1, strLine, "</p>") = 0 then
- GetNextLine = True
- strLine = ReplacePattern("target=""_blank"">", "target=""", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = Replace(strLine," ","")
- strLine = Replace(strLine,",",",")
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write strLine
- objStdOut.WriteLine "Writing Half Description"
- Else
- strLine = ReplacePattern("target=""_blank"">", "target=""", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = Replace(strLine," ","")
- strLine = Replace(strLine,",",",")
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write strLine
- objStdOut.WriteLine "Writing Description"
- End if
- End If
- If InStr(1, strLine, strSearchFor2) > 0 then
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write strLine & vbCrLf
- objStdOut.WriteLine "Writing UNIX Timestamp"
- End If
- If InStr(1, strLine, strSearchFor3) > 0 then
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = ReplacePattern("<[^>]*>", "", strLine)
- strLine = Replace(strLine,"<a href=","")
- strLine = Replace(strLine,""" target=""_blank"" rel=""nofollow"">Original Image</a></div>","")
- strLine = ReplacePattern("""http://.*/", "", strLine)
- strLine = Replace(strLine," ","")
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write "," & strLine & ","
- objStdOut.WriteLine "Writing Image file name (ID)"
- End If
- If InStr(1, strLine, strSearchFor4) > 0 then
- strLine = Replace(strLine,"<div class=""p-l-block""><span class=""fa fa-instagram""></span> <a href=""","")
- strLine = Replace(strLine,""" target=""_blank"">View in Instagram web page</a></div>","")
- strLine = Replace(strLine,vbCrLf,"")
- strLine = Replace(strLine,vbLf,"")
- out.Write strLine & ","
- objStdOut.WriteLine "Writing Instagram URL"
- End If
- If InStr(1, strLine, strSearchFor5) > 0 then
- objStdOut.WriteLine "Found Next page!"
- inurl = Replace(strLine,"<a href=""","")
- inurl = Replace(inurl,""" id=""next-link"">More »</a>","")
- strFileURL = "http://www.iphoneogram.com/" & inurl
- it=it+1
- strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
- Call getMeta(strFileURL,strHDLocation)
- End If
- Loop
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement