Jump to content

Reading more than 1 line at a time


Recommended Posts

#include <ColorConstants.au3>; Including required files
#include <GUIConstantsEx.au3>
#include <file.au3>
#include <Array.au3>
#include <string.au3>
Example()

Func Example()
Local $hash
Local $hashes = "hash.txt"
_FileReadToArray($hashes, $hash)
For $i = 1 to UBound($hash) -1
$hashcheck = $hash[$i]
$PDenc = "hash=" &  $hashcheck & "&decrypt=Decrypt"
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://URLHERE.com/", False) ; Post url
$oHTTP.SetRequestHeader("Host", "URLHERE.com")
$oHTTP.SetRequestHeader("Connection", "keep-aliveContent-Length: 29")
$oHTTP.SetRequestHeader("Cache-Control", "max-age=0")
$oHTTP.SetRequestHeader("Origin", "http://URLHERE.com")
$oHTTP.SetRequestHeader("Upgrade-Insecure-Requests", "1")
$oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36")
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
$oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
$oHTTP.SetRequestHeader("Referer", "http://URLHERE.com/")
$oHTTP.SetRequestHeader("Accept-Language", "en-US,en;q=0.8")
$oHTTP.Send($PDenc)
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status
; Saves the body response regardless of the Response code
$file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
FileWrite($file, $oReceived)
$read = FileRead("Received.html") ;read file
$Datastring = ('</script></div><br/>')
$newreadamount = _StringBetween($read, $Datastring, "</b><br/><br/>") ;read title from file
$newreadamount[0] = StringReplace($newreadamount[0], '<b>', "") ; taking out the X makes it easier to compare values
$file = FileOpen("decrypted.txt", 1)
FileWrite($file, $newreadamount[0] & @CRLF)
Next
EndFunc   ;==>Example

I would like to read up to 500 lines in my file at a time instead of reading the one line each time.
is this possible?

Lets say I have 500 lines in my document and I would like to add them all to the

$PDenc = "hash=" &  $hashcheck & "&decrypt=Decrypt"

$hashcheck variable.
Right now it will only take 1 line each time until all of it is finished.
But I would like it to take 500 lines each time to hasten the process.


Thanks in advance.

Edited by RyukShini
Link to comment
Share on other sites

Why not read the whole file and only process 500 lines from the resulting Array?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

1 minute ago, water said:

Why not read the whole file and only process 500 lines from the resulting Array?

Well I thought about that.
but how would I process 500 lines from the whole file?
and right now in my code don't I already read all of the file to the array?(Thats what I thought I did already?)
 

Link to comment
Share on other sites

Set the upper Limit in the Loop to 500.

For $i = 1 to 500

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I now hit another problem.
 

if StringInStr($read, "not found") Then
            SKIP
        Else
            ContinueLoop

Don't know if you understand, but I want to skip/continue if I receive "Not Found" in the HTML response.
I got it to work with if StringInStr................. Then
ExitLoop
But I am not looking to exit the loop, I am simply looking to ignore it and move on if "Not found" is triggered.
I am just not sure how/what to do to ignore/skip that response.

Thanks in advance

 

I believe I fixed it!
 

Edited by RyukShini
FIxed I think
Link to comment
Share on other sites

While 
    If Not StringInStr($read, "not found") Then
        ; process the string
    EndIf
WEnd

Edit: Just see you seem to have fixed it.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...