Dmitiy Posted February 21, 2022 Share Posted February 21, 2022 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. expandcollapse popup#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 More sharing options...
mikell Posted February 21, 2022 Share Posted February 21, 2022 Did you try _FileWriteToLine ? the doc says :If _FileWriteToLine() is called with $bOverWrite as 1 and $sText as "", it will delete the line. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 21, 2022 Developers Share Posted February 21, 2022 (edited) So you want to go round-robin through your list of 100 proxy servers going to the same website.... I wonder why one would really want that for a legitimate purpose? Edited February 21, 2022 by Jos Earthshine 1 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 More sharing options...
Dmitiy Posted February 21, 2022 Author Share Posted February 21, 2022 This is taken from the reference. _FileWriteToLine('100proxy.txt', 1, '', 1) Worked with this code for more than a year. All without errors. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 21, 2022 Developers Share Posted February 21, 2022 ... and what is the answer to my question? 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 More sharing options...
Dmitiy Posted February 22, 2022 Author Share Posted February 22, 2022 I had to split it into 2 files. expandcollapse popup#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 More sharing options...
Developers Solution Jos Posted February 22, 2022 Developers Solution Share Posted February 22, 2022 (edited) @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 February 22, 2022 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 More sharing options...
Recommended Posts