RyukShini Posted January 19, 2016 Posted January 19, 2016 My problem is that I wish my script to make a new received.html each run. I have looped everything and I got it to read my file as a loop in a msgbox. Right now I have stored some emails in email.txt All those emails is post data "$postcred" $oHTTP.Open("GET"), "" & $postcred, False) Later on I read the response and save the source/body of the site. It runs fine, however it only picks up the first line and I need it to run untill all lines are finished. Then for each file/request it should create a new .html file. Thanks in advance expandcollapse popup#include <String.au3> #include <Array.au3> #Include <File.au3> $oldreadamount = "Page Not" While 1 ; <--- start a loop to keep prog going Local $emails = "C:\Users\Gr3ndel\Desktop\autoit\Instagram\email.txt" ;sets file path Local $ArrayEmail[57] ;declares array _FileReadToArray($emails, $ArrayEmail) ;converts file to array For $i = 1 to UBound($ArrayEmail) -1) $postcred = (0,'',$ArrayEmail[$i]) Next ; The data to be sent $sPD = '' ; Post data/User information - You gotta update csrftoken if it reports errors / 404 codes ; Creating the object $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", "" & $postcred, False) ; Post url $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") ; Header data > $oHTTP.SetRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8") $oHTTP.SetRequestHeader("User-Agent", "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.52 YaBrowser/15.12.2490.3614 (beta) Yowser/2.5 Safari/537.36") $oHTTP.SetRequestHeader("X-CSRFToken", "472f9ab4b4cfe2ab9160648a2a957fcb") $oHTTP.SetRequestHeader("Referer", "") $oHTTP.SetRequestHeader("Cookie", "") $oHTTP.SetRequestHeader("X-Requested-With", "XMLHttpRequest") ; Header data < ; Performing the Request $oHTTP.Send($sPD) ;Sends the post data with the given details ;Download the body response if any, and get the server status response code. $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status If $oStatusCode <> 200 then MsgBox(4096, "Response code", $oStatusCode) EndIf ; Saves the body response regardless of the Response code $file = FileOpen("Received1.html", 2) ; The value of 2 overwrites the file if it already exists FileWrite($file, $oReceived) FileClose($file) $read = FileRead("Received1.html") ;read file $Datastring = ('<title>') $newreadamount = _StringBetween($read,$Datastring, "</title>") ;read title from file If $oldreadamount = "" Then MsgBox($newreadamount, "") EndIf Sleep(5000) ; wait 2 minutes before looking again $oldreadamount = $newreadamount[0] WEnd
RyukShini Posted January 19, 2016 Author Posted January 19, 2016 I would really appreciate some help. if it is my grammar and/or if I explained myself poorly, please let me know.
Developers Jos Posted January 19, 2016 Developers Posted January 19, 2016 @RyukShini, Please do not bump your own threads within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. 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.
Jfish Posted January 19, 2016 Posted January 19, 2016 You realize there is no way to escape your while loop ... so that is an infinite loop? Instead, consider using only the for loop and having it finish when all the rows of the array are completed. At present, that outer loop is making all the stuff inside it repeat over and over again. However, the result is that it will create an array and probably send only the last element in the array (because you looped them all and then it finished and $postcred had the last value in the loop). You have no code to send the other 56 elements. In summary, try removing the outer while loop and moving your logic inside the for loop. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
RyukShini Posted January 19, 2016 Author Posted January 19, 2016 19 minutes ago, Jos said: @RyukShini, Please do not bump your own threads within 24 hours. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Jos I am sorry, I will remember that of course.
RyukShini Posted January 19, 2016 Author Posted January 19, 2016 13 minutes ago, Jfish said: You realize there is no way to escape your while loop ... so that is an infinite loop? Instead, consider using only the for loop and having it finish when all the rows of the array are completed. At present, that outer loop is making all the stuff inside it repeat over and over again. However, the result is that it will create an array and probably send only the last element in the array (because you looped them all and then it finished and $postcred had the last value in the loop). You have no code to send the other 56 elements. In summary, try removing the outer while loop and moving your logic inside the for loop. I know that it is not working and I seem to understand why. but I am struggling with configuring my script. I have looked around different places. but I can't seem to get it to work. I want each line from file inserted here "$line" $oHTTP.Open("GET", "" & $line, False) ; Post url I know how to get them there without looping and counting each line etc. but getting it to read from line 1 and to the end of the .txt and afterwards save the body response in .html each time it inserts a new username/loops. I am not sure if you can give me a clue or something to work with? Thanks in advance
Jfish Posted January 19, 2016 Posted January 19, 2016 Please re-read my post. You need to have that code in your FOR loop not your WHILE loop. You don't need the WHILE loop. I already explained why I think it is not working and how to fix it. Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
RyukShini Posted January 19, 2016 Author Posted January 19, 2016 8 minutes ago, Jfish said: Please re-read my post. You need to have that code in your FOR loop not your WHILE loop. You don't need the WHILE loop. I already explained why I think it is not working and how to fix it. Alright thank you. I will take another look on it from your instructions.
RyukShini Posted January 19, 2016 Author Posted January 19, 2016 14 minutes ago, Jfish said: Please re-read my post. You need to have that code in your FOR loop not your WHILE loop. You don't need the WHILE loop. I already explained why I think it is not working and how to fix it. For $i = 1 to UBound($ArrayEmail) -1 $oHTTP.Open("GET", "urlhere" & $ArrayEmail[$i], False) ; Post url Next This does not give me errors. It works as expected more or less. However instead of using the value from each line. It reads it all the way and inserts the last line of the file. I feel frustrated because everything has worked out well so far and now I am stuck.
Jfish Posted January 19, 2016 Posted January 19, 2016 (edited) Please post ALL you revised code. Also, I would add some error checking. I would recommend using _arrayDisplay to see what the array looks like. Make sure it contains the data in the format you expect. Edited January 19, 2016 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Moderators Melba23 Posted January 19, 2016 Moderators Posted January 19, 2016 RyukShini, When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote and it just pads the thread unnecessarily. Thanks for your cooperation. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now