UltimateNoob Posted June 7, 2014 Share Posted June 7, 2014 Hello, I am trying to edit a code in autoit. Currently the code will open a webpage and then load a page and cache the page into a folder for me. However, when it reloads the page I need it to fill in the red X with a number. Here is the line where I would like the numbers to be added _IENavigate($oIE, "http://www.testwebsite.com/start=X0") For example, I can start on "/start=10" but when my page refreshes I need it to display 20 then 30, 40, 50, 60, 70 and etc When it gets to 100 I need it to go to 100 and then 200, 300, 400, 500 and etc. It would be helpful if I could inform it on what number I would like it to stop at but if I cant, 1000 would be a great stopping point. ------I already have the rest of the entire code----- I just need help on getting autoit to add the numbers and then allow it to show up in the url when the screen refreshes THANKS SO MUCH in advance !!!! Link to comment Share on other sites More sharing options...
mikell Posted June 7, 2014 Share Posted June 7, 2014 (edited) Simple For loops will work $url = "http://www.testwebsite.com/start=" $txt = "" For $i = 1 to 9 $urltogo = $url & $i & "0" $txt &= $urltogo & @crlf Next For $i = 1 to 10 $urltogo = $url & $i & "00" $txt &= $urltogo & @crlf Next Msgbox(0,"", $txt) Edit or Local $url = "http://www.testwebsite.com/start=", $txt = "" For $i = 1 to 19 $urltogo = $url & (($i<10) ? $i : (Mod($i, 10)+1)*10)*10 $txt &= $urltogo & @crlf Next Msgbox(0,"", $txt) Edited June 7, 2014 by mikell UltimateNoob 1 Link to comment Share on other sites More sharing options...
abberration Posted June 7, 2014 Share Posted June 7, 2014 Another idea: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $num = 10 $Form1 = GUICreate("", 154, 44) $Button1 = GUICtrlCreateButton("Hit", 8, 8, 75, 25) $Label1 = GUICtrlCreateLabel($num, 104, 16, 36, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _NumHit() EndSwitch WEnd Func _NumHit() If $num > 90 AND $num < 1000 Then $num += 100 ElseIf $num < 100 Then $num += 10 EndIf GUICtrlSetData($Label1, $num) EndFunc Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Malkey Posted June 7, 2014 Share Posted June 7, 2014 And another. Local $url = "http://www.testwebsite.com/start=30" Local $iStop = 600 Local $sNewUrl = StringRegExpReplace($url, "^(.+?)\d+$", "${1}") & _NumHit(StringRegExpReplace($url, "^.+?(\d+)$", "${1}"), $iStop) MsgBox(0, "Result", "Old Url = " & $url & @LF & @LF & "New Url = " & $sNewUrl) Func _NumHit($num, $iEnd) If $num < $iEnd Then If $num >= 100 And $num < 1000 Then $num += 100 ElseIf $num < 100 Then $num += 10 EndIf Return $num Else Return $iEnd EndIf EndFunc ;==>_NumHit Link to comment Share on other sites More sharing options...
UltimateNoob Posted June 8, 2014 Author Share Posted June 8, 2014 (edited) Okay, so obviously I am the Ultimate Noob here at AutoITscript. And any of you helping me can obviously do this piece of code if you really wanted to LOL So I am still having problems. I would like the script to automatically go to the next page of google, by auto filling the last part of the url and the refreshing to the next search page, caching the current screen in my chosen folder. I have edited it to the best of my abilities but it just shoots right to page 1000. This is so awesome and so close I have posted the entire code below, hopefully someone can help me tweak it to work perfectly. THANK YOU everyone for posting all the codes you have. This AutoITscript stuff is intense, and I see that there are many ways for a question to be answered. There is just no simple fix to a broad question. So I hope by me posting the entire script can help all of you in assisting me in perfecting this script. expandcollapse popup#include <IE.au3> #include <array.au3> #Include <File.au3> #include <string.au3> #include <INet.au3> $googleProfilePage = InputBox("Profile Page", "Please enter the progile url?"); $i = 1;This will keep track of how many pofiles we have pulled from google $oIE = _IECreate($googleProfilePage);This will open the google Page While 1;This will run forever if $i = 1 Then;This is so it waits for me to login on the first one msgbox(1, "Ready?", "Let me know when you are ready?"); EndIf;This is so we skip this if we dont want to login If $i = 1001 Then; Msgbox(1, "Done", "I belive we are done"); EndIf $RandomSleepTime = Random(500, 2000);This will give a random wait time for the webpage $RandomSaveTime = Random (500, 1000);This will give a random sleep time for the saving of the data _IELoadWait($oIE);Waits for the webpage to load Sleep ($RandomSleepTime);Sleeps for assurance $googleData = _IEDocReadHTML($oIE);Reads the google HTML Sleep (100);This is a sleep for assurance $FileLocation = ("C:\Users\Donna\Desktop\google-scrape\profile_" & $i & ".html");This gives the file location as a varibale _FileCreate($FileLocation);This will create the file in the location specified FileOpen($FileLocation);This will open the file in that location FileWrite($FileLocation, $googleData);This will write the data to that location Sleep(500) $url = "https://www.google.com/search?q=test&start=" $txt = "" For $i = 1 to 9 $urltogo = $url & $i & "0" $txt &= $urltogo & @crlf Next For $i = 1 to 10 $urltogo = $url & $i & "00" $txt &= $urltogo & @crlf Next Sleep(500) _IENavigate($oIE, $urltogo ) Sleep ($RandomSaveTime);Sleeps for assurance $i = $i + 1;This will make it go to the next profile for orginization WEnd;This is for when we are done NEVER THANKS AGAIN!!!! Edited June 8, 2014 by UltimateNoob Link to comment Share on other sites More sharing options...
mikell Posted June 9, 2014 Share Posted June 9, 2014 If you want something faster you can do it like this $url = "https://www.google.com/search?q=test&start=" $dir = @desktopdir & "\google-scrape\" If not FileExists($dir) Then DirCreate($dir) For $i = 0 to 9 $urltogo = $url & $i & "0" $content = BinaryToString(InetRead($urltogo)) $FileLocation = $dir & "profile_" & $i & ".html" FileOpen($FileLocation, 1) ; open the file in writing mode FileWrite($FileLocation, $content) ;This will write the data to that location FileClose($FileLocation) Sleep(100) Next Link to comment Share on other sites More sharing options...
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