AU3Newb Posted November 23, 2011 Share Posted November 23, 2011 (edited) Resolved Edited November 25, 2011 by AU3Newb Link to comment Share on other sites More sharing options...
jvanegmond Posted November 23, 2011 Share Posted November 23, 2011 My grandma could make this in 5 minutes and she doesn't even know what the mouse is for. Far too simple a question. Your program consists of: - Read input - A loop of a range of numbers (programmers call this a "For" loop) - Write output to a file - Download a webpages source The only hard part is the download webpage source, but the help file is quite explicit about you can do that easily. So.. I don't see what the problem is here. I've attached a script. First I was going to write like a pseudo-code (it means: It looks like code but isnt code because a computer doesnt understand it), but writing the entire thing is easier. #include <INet.au3> $Start = InputBox("", "Start") $Finish = InputBox("", "Finish") For $i = $Start To $Finish $url = "DOMAIN/page/" & $i $source _INetGetSource($url) FileWrite("output.txt", "================================" & @CRLF) FileWrite("output.txt", $url & @CRLF) FileWrite("output.txt", $source & @CRLF) FileWrite("output.txt", "================================" & @CRLF & @CRLF) Next Now what you have to do: Modify this script to your own wishes. It's far from perfect, but it illustrates the basics. This is much more than I wanted to give you, so don't come begging without effort next time. github.com/jvanegmond Link to comment Share on other sites More sharing options...
JohnOne Posted November 23, 2011 Share Posted November 23, 2011 Try this For $i = 10 To 20 InetGet("http://www.my.website.php?page=" & $i,@ScriptDir & "\page" & $i & ".txt",1) Next AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted November 23, 2011 Share Posted November 23, 2011 Well if nothing else, it's still worth noting for future if you feel like optimizing your script at some point. Keep in mind that with InetGet() you can have multiple parallel downloads, which could optimize speed. It would, of course, mean that you would have to parse the downloaded files upon completion, into one file. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted November 25, 2011 Share Posted November 25, 2011 If you are not prepared to show the code that you are having problems with, and rather just assume no-one knows how to achieve what you want because there is not a boil in the bag code posted for you, then you are unlikely to get much help here. So far you have shown zero effort. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted November 25, 2011 Share Posted November 25, 2011 (edited) If you look at the documentation for InetGet(), you will see that with background set to 1You need to check the download status with InetGetInfo().At the moment your code is not, so you have no Idea when the downloads are complete.If the number of downloads is only known at runtime, then you would need to create an arrayto hole the InetGet Handles in order to be able to check them.If you cannot get your head around that, then perhaps another way such as InetRead mightbe a better option.Here is a very basic example, which is untested.Local $sFinalString = '' ;empty string which will hold all the source strings Local $sWorkingString = '' ; this one will be used in the loop For $i = 10 To 20 $sWorkingString = InetRead("http://www.my.website.php?page=" & $i,1) ; ; downloads into a variable the source of the page (Binary) $sWorkingString = BinaryToString($sWorkingString) ; convert binary to readable string ;Adding your info and working string to final string $sFinalString &= "http://www.my.website.php?page=" & $i & @CRLF $sFinalString &= "Any more info you want "& @CRLF & @CRLF $sFinalString &= $sWorkingString & @CRLF & @CRLF Next FileWrite("yourfilepathandname.txt" ,$sFinalString) ; write the data to a file Edited November 25, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jvanegmond Posted November 25, 2011 Share Posted November 25, 2011 (edited) You still haven't figured out the mistake in my code? It was a missing = sign, just like the error said. $source _INetGetSource($url) should be: $source = _INetGetSource($url) Complete code: #include <inet.au3> $Start = InputBox("", "Start") $Finish = InputBox("", "Finish") For $i = $Start To $Finish $url = "http://www.google.com/search?q=" & $i $source = _INetGetSource($url) FileWrite("output.txt", "================================" & @CRLF) FileWrite("output.txt", $url & @CRLF) FileWrite("output.txt", $source & @CRLF) FileWrite("output.txt", "================================" & @CRLF & @CRLF) Next Edited November 25, 2011 by Manadar AU3Newb 1 github.com/jvanegmond Link to comment Share on other sites More sharing options...
jvanegmond Posted November 25, 2011 Share Posted November 25, 2011 Find and replace in AutoIt is called "StringReplace". The help file explains how it works. Hope that's enough. github.com/jvanegmond 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