Sign in to follow this  
Followers 0
AU3Newb

Resolved

8 posts in this topic

#1 ·  Posted (edited)

Resolved

Edited by AU3Newb

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you look at the documentation for InetGet(), you will see that with background set to 1

You 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 array

to 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 might

be 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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Manadar
1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0