Advertisement
DeviousMalcontent

InstaMeta_v2.0_w.vbs

Aug 8th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Name: InstaMeta WScript Version 2.0
  2. ' File: InstaMeta_v2.0_w.vbs
  3. ' Licence: N/A
  4. ' Author: Mark Albanese (Devious_Malcontent)
  5. ' Date: 3 August 2014
  6. ' Version: 2.0
  7. ' Release: 1
  8. ' Language: VBScript
  9. ' Compiler: N/A
  10. ' Notes: Your Instagram account must be public.
  11. '    Default encoding is ANSI, however this can be changed to UTF by opening the file in notepad and saving it as UTF format.
  12. ' Usage: Save as "InstaMeta_v2.0_w.vbs"
  13. '    Run this by double clicking on the file name in Windows, enter Instagram username when prompted,
  14. '        wait for the program to respond with done and then the output filename.
  15.  
  16. Set objFSO = Createobject("Scripting.FileSystemObject")
  17. Set objShell = wscript.createobject("wscript.shell")
  18.  
  19. username = InputBox("Please enter Instagram Username:", "Instagram Username")
  20. OutputFileName = username & "_Instagram_Metadata" & Replace(Replace(Replace(FormatDateTime(Now()),"/","."),":",".")," ","_") & ".csv"
  21.  
  22. it=1
  23.  
  24. strFileURL = "http://www.iphoneogram.com/" & username
  25. strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
  26.  
  27. Dim objFile, strLine, out
  28. Set out = objFSO.OpenTextFile(objShell.CurrentDirectory & "\" & OutputFileName, 2, True)
  29.  
  30. Call getMeta(strFileURL,strHDLocation)
  31. objFile.Close
  32.  
  33. Do Until it=0
  34.     strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
  35.         If objFSO.Fileexists(strHDLocation) Then
  36.             objFSO.DeleteFile strHDLocation
  37.         End If
  38.     it=it-1
  39. Loop
  40.  
  41. Set objFSO = Nothing
  42.  
  43. Wscript.Echo "Done! Output File Name: " & OutputFileName
  44. Function ReplacePattern(patrn, replStr, str1)
  45.   Dim regEx
  46.  
  47.   Set regEx = New RegExp
  48.   regEx.Pattern = patrn
  49.   regEx.IgnoreCase = True
  50.  
  51.   ReplacePattern = regEx.Replace(str1, replStr)
  52. End Function
  53.  
  54. Sub getMeta(strFileURL,strHDLocation)
  55.    
  56. Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  57.  
  58. objXMLHTTP.open "GET", strFileURL, false
  59. objXMLHTTP.send()
  60.  
  61. If objXMLHTTP.Status = 200 Then
  62. Set objADOStream = CreateObject("ADODB.Stream")
  63. objADOStream.Open
  64. objADOStream.Type = 1
  65.  
  66. objADOStream.Write objXMLHTTP.ResponseBody
  67. objADOStream.Position = 0
  68.  
  69. If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
  70.     objADOStream.SaveToFile strHDLocation
  71.     objADOStream.Close
  72.     Set objADOStream = Nothing
  73. End if
  74.  
  75. Set objXMLHTTP = Nothing
  76.  
  77. Set objFile = objFSO.OpenTextFile(strHDLocation, 1)
  78.  
  79. Dim strSearchFor1, strSearchFor2, strSearchFor3, strSearchFor4, strSearchFor5
  80. strSearchFor1 = "text com"
  81. strSearchFor2 = "p-time-block"
  82. strSearchFor3 = "Original Image"
  83. strSearchFor4 = "View in Instagram web page"
  84. strSearchFor5 = "id=""next-link"">More"
  85.  
  86. GetNextLine = False
  87.  
  88. Do While Not objFile.AtEndOfStream
  89.         strLine = objFile.readline
  90.        
  91.         If GetNextLine = True Then
  92.             If InStr(1, strLine, "</p>") > 0 then
  93.                 GetNextLine = False
  94.             End If
  95.            
  96.             strLine = Replace(strLine,",","&#44;")
  97.             strLine = Replace(strLine,"</p>"," ")
  98.             strLine = Replace(strLine,vbCrLf,"")
  99.             strLine = Replace(strLine,vbLf,"")
  100.  
  101.             out.Write " " & strLine
  102.         End If
  103.        
  104.         If InStr(1, strLine, strSearchFor1) > 0 then
  105.        
  106.             If InStr(1, strLine, "</p>") = 0 then
  107.                 GetNextLine = True
  108.                
  109.                 strLine = ReplacePattern("target=""_blank"">", "target=""", strLine)
  110.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  111.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  112.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  113.                 strLine = Replace(strLine," &nbsp; ","")
  114.                 strLine = Replace(strLine,",","&#44;")
  115.                 strLine = Replace(strLine,vbCrLf,"")
  116.                 strLine = Replace(strLine,vbLf,"")
  117.  
  118.                 out.Write strLine
  119.             Else
  120.                 strLine = ReplacePattern("target=""_blank"">", "target=""", strLine)
  121.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  122.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  123.                 strLine = ReplacePattern("<[^>]*>", "", strLine)
  124.                 strLine = Replace(strLine," &nbsp; ","")
  125.                 strLine = Replace(strLine,",","&#44;")
  126.                 strLine = Replace(strLine,vbCrLf,"")
  127.                 strLine = Replace(strLine,vbLf,"")
  128.  
  129.                 out.Write strLine
  130.             End if
  131.         End If
  132.                    
  133.         If InStr(1, strLine, strSearchFor2) > 0 then
  134.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  135.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  136.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  137.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  138.           strLine = Replace(strLine,vbCrLf,"")
  139.           strLine = Replace(strLine,vbLf,"")
  140.          
  141.           out.Write strLine & vbCrLf
  142.         End If
  143.        
  144.         If InStr(1, strLine, strSearchFor3) > 0 then
  145.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  146.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  147.           strLine = ReplacePattern("<[^>]*>", "", strLine)
  148.           strLine = Replace(strLine,"<a href=","")
  149.           strLine = Replace(strLine,""" target=""_blank"" rel=""nofollow"">Original Image</a></div>","")
  150.           strLine = ReplacePattern("""http://.*/", "", strLine)
  151.           strLine = Replace(strLine," ","")
  152.           strLine = Replace(strLine,vbCrLf,"")
  153.           strLine = Replace(strLine,vbLf,"")
  154.          
  155.           out.Write "," & strLine & ","
  156.         End If
  157.        
  158.         If InStr(1, strLine, strSearchFor4) > 0 then
  159.           strLine = Replace(strLine,"<div class=""p-l-block""><span class=""fa fa-instagram""></span> <a href=""","")
  160.           strLine = Replace(strLine,""" target=""_blank"">View in Instagram web page</a></div>","")
  161.           strLine = Replace(strLine,vbCrLf,"")
  162.           strLine = Replace(strLine,vbLf,"")
  163.          
  164.           out.Write strLine & ","
  165.         End If
  166.        
  167.         If InStr(1, strLine, strSearchFor5) > 0 then
  168.          
  169.           inurl = Replace(strLine,"<a href=""","")
  170.           inurl = Replace(inurl,""" id=""next-link"">More &raquo;</a>","")
  171.          
  172.           strFileURL = "http://www.iphoneogram.com/" & inurl
  173.           it=it+1
  174.           strHDLocation = objShell.CurrentDirectory & "\page" & it & ".html"
  175.           Call getMeta(strFileURL,strHDLocation)
  176.         End If
  177.     Loop
  178. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement