Sign in to follow this  
Followers 0
phew

several google results

6 posts in this topic

#1 ·  Posted (edited)

hi,

i wrote a little google script:

(...)
Func _google()
For $i = 0 To 4 Step 1
    If (GUICtrlRead($cb_logfile) = 1) Then 
        FileOpen("logfile.log", 1)
    ElseIf (GUICtrlRead($cb_results) = 1) Then
        FileOpen("results.txt", 1)
    EndIf
    $page = "/search?q=" & $search & "&hl=de&start=" & $i & "0&sa=N"
    $start = 1
    TCPStartup()
    $socket = TCPConnect(TCPNameToIP('www.google.de'), 80)
    $command = "GET " & $page & " HTTP/1.1" & @CRLF
    $command &= "Host: " & $host & @CRLF
    $command &= "User-Agent: " & "phew/rfi" & @CRLF
    $command &= "Connection: close"&@CRLF
    $command &= ""&@CRLF
    TCPSend($socket, $command)
Next
EndFunc
(...)
While (1)
    If ($start = 1) Then
        $srcv = TCPRecv($socket, 1288)
        If ($srcv <> "") Then           
                     $x = FileOpen("x.txt", 1)
                     FileWriteLine($x, $srcv)
        EndIf
    EndIf

i want my script to save the $srcv (quelltext of google results website) in my "x.txt", and this for the first 5 result-pages of google. but when i open the logfile "x.txt" there is only the last website's quelltext in it, why?

Edited by phew

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Because your fileopen command is inside your loop and it's set to OVERWRITE PREVIOUS CONTENTS

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Because your fileopen command is inside your loop and it's set to OVERWRITE PREVIOUS CONTENTS

Mode (read or write) to open the file in.

Can be a combination of the following:

0 = Read mode

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

no it isn't

Share this post


Link to post
Share on other sites

sry for bump, but no one got an idea?

Share this post


Link to post
Share on other sites

sry for bump, but no one got an idea?

You were given an answer... you can't really have a FileOpen() if you don't ever use a FileClose().

Why not just use InetGetSource() or InetGet()?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

You were given an answer... you can't really have a FileOpen() if you don't ever use a FileClose().

Why not just use InetGetSource() or InetGet()?

i had a fileclose() somewhere where the (...) code continued but i already fixed it with InetGetSource() and InetGet() but thanks for the suggestion =)

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