Suan Posted May 29, 2015 Share Posted May 29, 2015 (edited) Hi Autoit Experts,I am pretty new to AutoIt, and have this requirement, where I have to download the content of a webpage using Autoit. I have tried InetGet() but the downloaded file contains HTML of the web page without the content of the webpage.Is there a way I can achieve this. The download format I want to get it CSV or TXT files.Thanks upfront.Regards,Suan. Edited May 29, 2015 by Suan Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 30, 2015 Moderators Share Posted May 30, 2015 Suan,Welcome to the AutoIt forum.But please pay attention to where you post - the "Dev Chat" section where you started this thread is not for general support questions. I have moved it for you, but would ask you to be more careful in future.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Suan Posted June 1, 2015 Author Share Posted June 1, 2015 Hi Melba23,Thank you. I assure you, I will be careful in the future. My apology.Suan. Link to comment Share on other sites More sharing options...
antfuentes87 Posted June 1, 2015 Share Posted June 1, 2015 (edited) I created this simple function to retrieve any web page. You can then do whatever you want with the data after that (write it to a file, etc...). Let me know if you have any questions.Func _HTTP_ResponseText($URL) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $URL) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)") $oHTTP.Send() return $oHTTP.ResponseText EndFunc Edited June 1, 2015 by antfuentes87 Suan 1 Link to comment Share on other sites More sharing options...
Suan Posted June 1, 2015 Author Share Posted June 1, 2015 Hi A87,Thanks for the response. The website from which I need to retrieve the info is password protected.Is there a way that I can achieve this? I have found it for IE, but I want it for Chrome, Firefox etc.If you could provide me this, I would be most grateful.Thanks.Suan Link to comment Share on other sites More sharing options...
Suan Posted June 1, 2015 Author Share Posted June 1, 2015 I am now able to connect it using the below code. Thanks again A87. #include <INet.au3>#include <String.au3>$URL = "url123456"Global $loginBody = "username=myusername&password=myapassword&autologin=on"$source = _HTTP_ResponseText($URL)FileWrite(@ScriptDir & "\winhttp.winhttprequest.5.1.html",$source); $read = FileRead(@ScriptDir & "\winhttp.winhttprequest.5.1.html") $readtitle = _StringBetween($read, "<head>","</head>") ;read title from fileMsgBox(0,"",$readtitle[0]) ;display first found stringFunc _HTTP_ResponseText($URL) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $URL) $oHTTP.SetRequestHeader("Content-Type","application/x-www-form-urlencoded") MsgBox (0, "", "URL : " &$URL) $oHTTP.Send($loginBody) return $oHTTP.ResponseTextEndFuncUsing the above code, I am able to log in. But only issue is it takes me to a different url location different from url123456. Any idea how to fix this? Regards,Suan Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now