Advertisement
Ex0rpl4net

Scraper.exe

Aug 1st, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  3. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  4. #SingleInstance off
  5.  
  6.  
  7. ;scraper.exe
  8.  
  9.  
  10. /*
  11. start:
  12. InputBox, urlinput , Input the url! ,&page= at the end,,500,100
  13. if !urlinput
  14. {
  15. msgbox,no input! fuk u press f11 to exit
  16. goto,start
  17. }
  18. */
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. firstpage = %1%
  27.  
  28. lastpage = %2%
  29.  
  30. urlinput = %3%
  31.  
  32. ;msgbox,the main url is:`n%urlinput%`n`nthe starting page is:%1%`n`nthe ending page is:%2%`noutput path is: %4%
  33.  
  34.  
  35. Run, cmd.exe,,, PID
  36. WinWait,ahk_pid %PID%
  37. WinMove,ahk_pid %PID%,,,,250, 200
  38. loop
  39. {
  40.  
  41. IfWinNotExist,Ex0rscraper%A_Index%
  42. {
  43. currentwin = Ex0rscraper%A_Index%
  44.  
  45. break
  46. }
  47. }
  48.  
  49. WinSetTitle,ahk_pid %PID%,,%currentwin%
  50. ;WinSet,region,w200 h300,ahk_pid %PID%
  51. Sleep, 1000
  52. DllCall("AttachConsole", "UPtr", PID)
  53. SetTimer, checkcmd, 500
  54. loopall := lastpage - firstpage
  55. loopall++
  56. loop,%loopall%
  57. {
  58. url = %urlinput%%firstpage%
  59.  
  60. try ; Attempts to execute code.
  61. {
  62.  
  63. loop
  64. {
  65. html:= URLDownloadToVar(url)
  66.  
  67. if (!html)
  68. {
  69. FileAppend, `nRetrying %firstpage%/%2%, CONOUT$
  70. sleep,%4%
  71. }
  72. if (html)
  73. break
  74. }
  75.  
  76. ;msgbox,%html%`n`n%currentwin%`n`n%url%
  77. }
  78.  
  79. catch e ; Handles the first error/exception raised by the block above.
  80. {
  81. ;shut up >:d
  82. }
  83.  
  84.  
  85.  
  86.  
  87. FileAppend, `nScraped %firstpage%/%2%, CONOUT$
  88. infotext = %infotext%`nScraped %firstpage%/%2%
  89.  
  90.  
  91. allusers = %allusers%`n%html%
  92.  
  93. firstpage++
  94. }
  95. /*
  96. select:
  97. FileSelectFile,selection,S11,,Select the txt file the usernames should be extracted too (%currentwin%),*.txt
  98. if (Errorlevel = 1)
  99. {
  100. msgbox,4,Do you want to close without saving?`n(all usernames scraped in this thread will be lost)
  101. IfMsgBox No
  102. goto,select
  103.  
  104. IfMsgBox Yes
  105. exitapp
  106.  
  107. }
  108. */
  109. sort,allusers,U
  110. FileAppend,%allusers%,scraped.txt
  111. TrayTip,%currentwin%, Completed Scraping!`nclosing now, 3, 1
  112.  
  113. sleep,3000
  114. winclose,%currentwin%
  115. exitapp
  116. GuiClose:
  117. exitapp
  118. f11::exitapp
  119.  
  120.  
  121. return
  122. URLDownloadToVar(url){
  123. hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
  124. hObject.Open("GET",url)
  125. hObject.Send()
  126. return hObject.ResponseText
  127. }
  128.  
  129.  
  130. return
  131.  
  132. checkcmd:
  133.  
  134. IfWinNotExist,%currentwin%
  135. {
  136. exitapp
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement