Advertisement
Guest User

Untitled

a guest
Apr 18th, 2010
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public dAmt, dAmt2 As Double
  4. Public IE, IE2, sMainHtml, sHtml, sSubHtml, sDataCheck1, sDataCheck2, sHome, sAway, sUrl, sKeyword, ft, sLink
  5. Public iPlace, iRow, iRow2, iCol, iCol2, iStart, iEnd, i, P, iCount As Integer
  6. Public dStart, dEnd, dRow, dRow2, dRow3, dHome, dDraw, dAway, dCheck, dWin As Double
  7. Public OptionArray(1000), DataArray(1000, 20)
  8. Public sThisbook, sTitle, sMsg As String
  9. Public objForms, objForm, objInputElement, objInputElement2
  10. Public dStarttime, dChecktime As Date
  11. Public bisitfast As Boolean
  12.  
  13. Sub StartPosting()
  14.  
  15. dAmt = Range("d8")
  16. dStarttime = TimeValue(Now() + TimeValue("00:00:01"))
  17. Call GetHtml("www.nashprojects.com")
  18. dAmt2 = 0
  19. Do Until dAmt = dAmt2
  20. tryagain:
  21. 'http://www.xtremetop100.com/in.php?site=1132297863'
  22. IE.navigate ("http://www.xtremetop100.com/in.php?site=1132297863")
  23. Application.Wait (Now() + TimeValue("00:00:05"))
  24. If InStr(1, UCase(IE.document.body.innerhtml), "CANNOT BE FOUND", 0) > 0 Then
  25. IE.navigate ("http://www.xtremetop100.com/in.php?site=1132297863")
  26. Application.Wait (Now() + TimeValue("00:00:05"))
  27. End If
  28.  
  29. Call WaitTillFinished
  30. If bisitfast = False Then GoTo tryagain
  31. Application.Wait (Now() + TimeValue("00:00:04"))
  32.  
  33. If IE.locationurl <> "http://www.xtremetop100.com/in.php?site=1132297863" Then
  34. GoTo tryagain
  35. End If
  36.  
  37. sHtml = IE.document.body.innerhtml
  38. 'Range("a1") = sHtml
  39. If InStr(1, UCase(sHtml), "YOU DON'T HAVE PERMISSION", 0) > 0 Then GoTo tryagain
  40. If InStr(1, UCase(sHtml), "CANNOT DISPLAY", 0) > 0 Then GoTo tryagain
  41. If InStr(1, UCase(sHtml), "CANNOT BE FOUND", 0) > 0 Then GoTo tryagain
  42. If InStr(1, UCase(sHtml), UCase("Generated"), 0) > 0 Then GoTo tryagain
  43. 'Generated
  44. iPlace = InStr(1, IE.document.body.innerhtml, "DISPLAY: block", 0)
  45. Do Until Mid(IE.document.body.innerhtml, iPlace, 3) = "src"
  46. iPlace = iPlace + 1
  47. Loop
  48. iPlace = iPlace + 5
  49. iStart = iPlace
  50. iPlace = iPlace + 2
  51. Do Until Mid(IE.document.body.innerhtml, iPlace, 1) = Chr(34)
  52. iPlace = iPlace + 1
  53. Loop
  54.  
  55. Call NPDelete_File(ActiveWorkbook.Path & ".\Captcha.jpg")
  56. Call SaveWebFile(Mid(IE.document.body.innerhtml, iStart, iPlace - iStart), ActiveWorkbook.Path & ".\Captcha.jpg")
  57. Call SolveCaptcha("ggn25f8yup8a33frzgsw3r5i7f3iovuedgf76e", Application.Path & ".\Captcha.jpg")
  58.  
  59. 'call wait
  60. If InStr(1, UCase(IE2.document.body.innerhtml), "YOU DON'T HAVE PERMISSION", 0) > 0 Or InStr(1, UCase(IE2.document.body.innerhtml), "CANNOT DISPLAY", 0) > 0 Then
  61. IE2.Quit
  62. GoTo tryagain
  63. End If
  64. If InStr(1, UCase(IE2.document.body.innerhtml), "CANNOT BE FOUND", 0) > 0 Or InStr(1, UCase(IE2.document.body.innerhtml), "WEBSITE DECLINED", 0) > 0 Then
  65. IE2.Quit
  66. GoTo tryagain
  67. End If
  68.  
  69. sKeyword = Trim(Mid(IE2.document.body.innerhtml, InStr(1, IE2.document.body.innerhtml, "<TD>", 0) + 4, InStr(1, IE2.document.body.innerhtml, "</TD>", 0) - InStr(1, IE2.document.body.innerhtml, "<TD>", 0) - 4))
  70. IE2.Quit
  71. Application.Wait (Now() + TimeValue("00:00:06"))
  72. Do Until TimeValue(Now()) > TimeValue(dStarttime)
  73. Application.Wait (Now() + TimeValue("00:00:02"))
  74. Application.StatusBar = "Waiting until " & TimeValue(dStarttime)
  75. Loop
  76. Application.StatusBar = False
  77.  
  78. Set objForms = IE.document.forms
  79. 'Test to see if there are forms before proceding
  80. Set objForm = objForms(0)
  81. i = 1
  82. For Each objInputElement In objForm
  83. ' MsgBox objInputElement.Name
  84. If i = 3 Then
  85. objInputElement.Focus
  86. objInputElement.Value = sKeyword
  87. 'Exit For
  88. ElseIf UCase(objInputElement.Name) = UCase("Submit") Then
  89. objInputElement.Focus
  90. objInputElement.Click
  91. Exit For
  92. End If
  93. i = i + 1
  94. Next
  95. Call WaitTillFinished
  96. 'MsgBox sKeyword
  97. dAmt2 = dAmt2 + 1
  98. dStarttime = TimeValue(Now() + TimeValue("00:02:01"))
  99. Loop
  100.  
  101. MsgBox dAmt & " posted"
  102.  
  103. End Sub
  104.  
  105. Sub GetHtml(sUrl)
  106.  
  107. Set IE = CreateObject("InternetExplorer.Application")
  108. IE.Visible = True 'if you want to see the browser window, but not necessary
  109. IE.navigate sUrl 'place your desired URL here
  110.  
  111. End Sub
  112.  
  113. Sub GetSecondIe()
  114.  
  115. Set IE2 = CreateObject("InternetExplorer.Application")
  116. IE2.Visible = True 'if you want to see the browser window, but not necessary
  117. IE2.navigate sUrl 'place your desired URL here
  118.  
  119. End Sub
  120.  
  121. Sub SolveCaptcha(sKey, sFile)
  122.  
  123. Call GetSecondIe
  124. StartAgain:
  125. IE2.navigate "http://www.beatcaptchas.com/captcha.php"
  126. While IE2.Busy
  127. DoEvents
  128. Wend
  129. NavigateWait:
  130. Application.Wait (Now() + TimeValue("00:00:03"))
  131. If IsError(IE2.document.body.innerhtml) = True Then GoTo NavigateWait
  132. sSubHtml = IE2.document.body.innerhtml
  133. Do Until InStr(1, UCase(sSubHtml), UCase("Submit"), 0) > 0
  134. sSubHtml = IE2.document.body.innerhtml
  135. Loop
  136. Application.Wait (Now() + TimeValue("00:00:02"))
  137.  
  138. On Error GoTo StartAgain
  139. Set objForms = IE2.document.forms
  140. dRow = 2
  141. If objForms.Length <> 0 Then
  142. Set objForm = objForms(0)
  143. i = 1
  144. For Each objInputElement In objForm
  145. If UCase(objInputElement.Type) = "FILE" Then
  146. Application.Wait (Now() + TimeValue("00:00:01"))
  147. objInputElement.Focus
  148. Application.Wait (Now() + TimeValue("00:00:01"))
  149. 'objInputElement.Click
  150. 'Application.Wait (Now() + TimeValue("00:00:03"))
  151. SendKeys sFile
  152. ElseIf UCase(objInputElement.Name) = UCase("KEY") Then
  153. objInputElement.Value = sKey
  154. ElseIf UCase(objInputElement.Name) = UCase("SUBMIT") Then
  155. Application.Wait (Now() + TimeValue("00:00:01"))
  156. objInputElement.Focus
  157. Application.Wait (Now() + TimeValue("00:00:01"))
  158. objInputElement.Click
  159. objInputElement.Click
  160. objInputElement.Click
  161. End If
  162. Next
  163. End If
  164.  
  165. While IE2.Busy
  166. DoEvents
  167. Wend
  168.  
  169. NavigateWait2:
  170. Application.Wait (Now() + TimeValue("00:00:03"))
  171. If IsError(IE2.document.body.innerhtml) = True Then GoTo NavigateWait2
  172. Application.Wait (Now() + TimeValue("00:00:04"))
  173.  
  174. sSubHtml = IE2.document.body.innerhtml
  175. If InStr(1, UCase(sSubHtml), "ERROR IF YOU HAVE JUST PURCHASED", 0) > 0 Then
  176. MsgBox ("There is an error, the Captchas cannot be retrieved as yet")
  177. End If
  178.  
  179.  
  180. End Sub
  181.  
  182. Sub WaitTillFinished()
  183.  
  184. dChecktime = TimeValue(Now())
  185. bisitfast = True
  186. While IE.Busy
  187. Application.Wait (Now() + TimeValue("00:00:01"))
  188. If Format(TimeValue(Format(Now(), "hh:mm:ss")) - TimeValue(Format(dStarttime, "hh:mm:ss")), "hh:mm:ss") > Format(TimeValue("00:01:30"), "HH:MM:SS") Then
  189. bisitfast = False
  190. Exit Sub
  191. End If
  192. Wend
  193.  
  194. End Sub
  195.  
  196. Sub NPDelete_File(sfilename)
  197.  
  198. 'MsgBox sfilename
  199. On Error GoTo FileNotFound
  200. Set ft = CreateObject("Scripting.FileSystemObject")
  201. ft.DeleteFile sfilename, True
  202.  
  203. 'Application.StatusBar = "File deleted successfully"
  204.  
  205. ExitIT:
  206.  
  207. Exit Sub
  208.  
  209. FileNotFound:
  210. 'Application.StatusBar = "File not found"
  211. Application.Wait (Now() + TimeValue("00:00:01"))
  212. Resume ExitIT
  213.  
  214. End Sub
  215. Function SaveWebFile(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
  216.  
  217. Dim oXMLHTTP As Object, vFF As Long, oResp() As Byte
  218. 'You can also set a ref. to Microsoft XML, and Dim oXMLHTTP as MSXML2.XMLHTTP
  219. Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
  220. oXMLHTTP.Open "GET", vWebFile, False 'Open socket to get the website
  221. oXMLHTTP.send 'send request
  222.  
  223. 'Wait for request to finish
  224. Do While oXMLHTTP.readyState <> 4
  225. DoEvents
  226. Loop
  227.  
  228. oResp = oXMLHTTP.responseBody 'Returns the results as a byte array
  229.  
  230. 'Create local file and save results to it
  231. vFF = FreeFile
  232. If Dir(vLocalFile) <> "" Then Kill vLocalFile
  233. Open vLocalFile For Binary As #vFF
  234. Put #vFF, , oResp
  235. Close #vFF
  236.  
  237. 'Clear memory
  238. Set oXMLHTTP = Nothing
  239. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement