[Autoit]HTTP Source Grabber - UDF - GUI - Function 04-10-2012, 01:12 PM
#1
This bit will grab the source of a webpage for you. It does NOT however, grab resources such as images.
Attached is a ZIP Archive with the two *.au3 files i worked from.
Here is the UDF to implement into any script. Just fill out the paramters when calling the function name
Here is a simple demonstration with the UDF and input boxes (no gui)
Lastly, here is a GUI demonstration
Attached is a ZIP Archive with the two *.au3 files i worked from.
Here is the UDF to implement into any script. Just fill out the paramters when calling the function name
Code:
Func _LeechPageSource($URL, $FILENAME)
$FILE_WRITE = FileOpen(@DesktopDir & "\" & $FILENAME & ".html", 1)
FileWrite($FILE_WRITE, _INetGetSource("http://" &$URL))
FileClose($FILE_WRITE)
MsgBox(64, "Success!", "File saved to your desktop!", 1)
EndFunc ;==>_LeechPageSourceHere is a simple demonstration with the UDF and input boxes (no gui)
Code:
#include <Inet.au3>
#include <file.au3>
_LeechPageSource()
Func _LeechPageSource()
$URL = InputBox("URL", "Type the URL which you would like to save the source of" & @CRLF & @CRLF & "NO 'WWW.' OR 'HTTP://' ")
If $URL ="" Then Return
$FILENAME = InputBox("Name", "Type the file name in which you would like to save." & @CRLF & @CRLF & "NO FILE EXTENSION")
If $FILENAME ="" Then Return
$html = FileOpen(@DesktopDir & "\" & $FILENAME & ".html", 1)
FileWrite($html, _INetGetSource("http://" &$URL))
FileClose($html)
MsgBox(64, "Success!", "File saved to your desktop!", 1)
EndFunc ;==>_LeechPageSourceLastly, here is a GUI demonstration
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Inet.au3>
#include <file.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("HTTP Source Grab | Jacob | HackCommunity.com | forum.delusionality.info", 280, 168, 192, 124)
$URLIN = GUICtrlCreateInput("", 125, 48, 121, 21)
$FILENAMEIN = GUICtrlCreateInput("", 125, 80, 121, 21)
$GRABUTTON = GUICtrlCreateButton("Grab!", 93, 120, 75, 25)
$Label3 = GUICtrlCreateLabel("Visit HackCommunity.com", 21, 16, 126, 17)
$Label5 = GUICtrlCreateLabel("Visit All Purpose-ality", 157, 16, 100, 17)
GUICtrlCreateLabel("URL", 61, 48, 26, 17)
GUICtrlCreateLabel("File Name", 61, 80, 51, 17)
GUICtrlCreateLabel("|", 149, 16, 6, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
MsgBox(48, "Warning!", "Make to NOT enter 'http:// OR www.' in the URL. Also do NOT enter a file extension!")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GRABUTTON
Global $READ_URL_GUI = GUICtrlRead($URLIN), $READ_FILENAME_GUI = GUICtrlRead($FILENAMEIN)
#cs
;Error Handling
;Return are NOT allowed on a global scale though
;Name the variables else where as GLOBAL.
;Then substitute function for variable to call the needed variable to read gui with error handling
If $READ_URL_GUI = "" Then
Return
ElseIf $READ_FILENAME_GUI = "" Then
Return
EndIf
OR
If $READ_URL_GUI = "" Then
MsgBox(0,'asdf','sdf')
ElseIf $READ_FILENAME_GUI = "" Then
MsgBox(0,'asdf','sdf')
EndIf
#ce
_LeechPageSource($READ_URL_GUI, $READ_FILENAME_GUI)
Case $Label5
ShellExecute("http://forum.delusionality.info")
Case $Label3
ShellExecute("http://hackcommunity.com")
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _LeechPageSource($URL, $FILENAME)
$FILE_WRITE = FileOpen(@DesktopDir & "\" & $FILENAME & ".html", 1)
FileWrite($FILE_WRITE, _INetGetSource("http://" & $URL))
FileClose($FILE_WRITE)
MsgBox(64, "Success!", "File saved to your desktop!", 1)
EndFunc ;==>_LeechPageSource
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)