Jump to content

How to delete a line?The script used to work.


Dmitiy
 Share

Go to solution Solved by Jos,

Recommended Posts

Hello.
For some reason, the first line in the '100proxy.txt' file is not deleted. I tried another function, the same thing.
The script used to work.

#include <File.au3>
#include <Array.au3>
#include <FileConstants.au3>

$t2 = 1; 
While $t2 <= 100;
pytdesat()
$t2 = $t2 + 1
WEnd


Func pytdesat();  
 $proxy = FileReadLine ( "100proxy.txt", 1);  reads 1 line from a file 
 
 $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
 $oErrorHandler = ObjEvent('AutoIt.Error', 'ErrorFunc')
 $oHTTP.Option(6) = False ;WinHttpRequestOption_EnableRedirects
 $oHTTP.Open("GET", "https://www.yandex.ru/", False);     
 $oHTTP.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0")
 $oHTTP.SetRequestHeader("Referer", "https://www.yandex.ru/") 
 $oHTTP.SetProxy(2, $proxy); 177.37.160.60:58033
 $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") 
 $oHTTP.Send("content"); send data and request a cookie
 $HeaderResponses = $oHTTP.GetAllResponseHeaders()

 $resp=$oHTTP.ResponseText
 ;I output the server response to the browser file
 FileWrite("console1.html", $HeaderResponses); get html page
 Sleep(2000)
 If FileExists("console1.html") Then FileWriteLine("proxy.txt", $proxy)
 Sleep(1000)
 ;----------- after using the proxy, delete the 1st line in the 100proxy.txt file-----
$no4 = FileReadLine ( "100proxy.txt",  1);     
$File = @ScriptDir & '\100proxy.txt'
$Read = FileRead($File)
$Replace = StringReplace($Read, $no4 & @CRLF, '');  change first line to empty value ''
FileDelete($File)
FileWrite($File, $Replace)
;----------------------------------second way-----------------------------------------
;Sleep(1000)
;_FileWriteToLine('100proxy.txt', 1, "", 1);change first line to empty value ''
;-------------------------------------------------------------------------------------
 Sleep(2000)
 FileDelete("console1.html")
 Sleep(2000)
 EndFunc
 
;----continue if error 
Func ErrorFunc()
    Exit 2   
EndFunc

 

Link to comment
Share on other sites

  • Developers

So you want to go round-robin through your list of 100 proxy servers going to the same website.... 

:think:  I wonder why one would really want that for a legitimate purpose? 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I had to split it into 2 files.

#include <File.au3>;
#include <Array.au3>
#include <FileConstants.au3>; 

$strok=_FileCountLines("100proxy.txt"); 
  
$t2 = 1; 
While $t2 <= $strok;
$proxy = FileReadLine ( "100proxy.txt", 1);  
Sleep(500)
FileWriteLine("1.txt", $proxy)
Sleep(500)

$process=ShellExecute("1.au3")
Sleep(2000)
While 1
   Sleep(1000) ;
If ProcessExists($process)==0 Then ExitLoop;  
WEnd

FileDelete("1.txt")
Sleep(500)
_FileWriteToLine('100proxy.txt', 1, '', 1);
Sleep(500)
$t2 = $t2 + 1
WEnd



;----------------------second file 1.au3-----------------------------
#include <File.au3>;
#include <Array.au3>
#include <FileConstants.au3>; 
 
 $proxy = FileReadLine ( "1.txt", 1); 
 
 $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
 $oErrorHandler = ObjEvent('AutoIt.Error', 'ErrorFunc')
 $oHTTP.Option(6) = False ;WinHttpRequestOption_EnableRedirects
 $oHTTP.Open("GET", "https://google.com/", False);       
 $oHTTP.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Firefox/60.0")
 $oHTTP.SetRequestHeader("Referer", "https://google.com/") 
 $oHTTP.SetProxy(2, $proxy); 177.37.160.60:58033
 $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") 
 $oHTTP.Send("captchasnet_captcha_content"); 
 $HeaderResponses = $oHTTP.GetAllResponseHeaders()
 $resp=$oHTTP.ResponseText 
 
 FileWrite("console1.html", $HeaderResponses); 
 Sleep(2000)
 If FileExists("console1.html") Then FileWriteLine("proxy.txt", $proxy)
 Sleep(1000) 
 FileDelete("console1.html")

 
Func ErrorFunc()
    Exit 2   
EndFunc

 

Link to comment
Share on other sites

  • Developers
  • Solution

@Dmitiy,

Your posting ability is revoked and I like to get first an answer to my question as I don't particularly like to be ignored. 
So PM me a satisfactory answer and I will restore your posting ability.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...