Kashgari Posted September 23, 2009 Share Posted September 23, 2009 (edited) Hi, I am trying to create a script to automate something with Firefox. It is in these steps. 1. Read a text file read each line in to array. (these are URL) 2. Use Firefox to visit each URL, loop until all the array finishes. 3. While visiting each line do something and move to next URL. I think this maybe easier with IE , but I want to use Firefox. I have read a lot of posts and help files, examples are either too easy or too difficult for me. Thanks. Edited September 23, 2009 by Kashgari Link to comment Share on other sites More sharing options...
dantay9 Posted September 23, 2009 Share Posted September 23, 2009 This udf by Stilgar is what you are looking for. Link to comment Share on other sites More sharing options...
Kashgari Posted September 23, 2009 Author Share Posted September 23, 2009 Thanks for your reply. I got it already. What I am looking for is a script which can do the task I have asked. Link to comment Share on other sites More sharing options...
dantay9 Posted September 23, 2009 Share Posted September 23, 2009 To read each line of a file, you can use _FileReadToArray or you can use FileReadLine in a loop. To visit websites, look at _FFStart and _FFOpenURL. To go through each url, loop through the array from _FileReadToArray or use FileReadLine each time. Post some code with what you have tried next time. Link to comment Share on other sites More sharing options...
Kashgari Posted September 24, 2009 Author Share Posted September 24, 2009 Ok, after reading number of posts and help file I come make following script, it looks fine but generates no result. Please help. #include <file.au3> #Include <FF.au3> Dim $aRecords If Not _FileReadToArray("url.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] _FFConnect() If _FFIsConnected() Then _FFOpenUrl($x,$aRecords[$x]) Sleep(5000) Endif Next Link to comment Share on other sites More sharing options...
Stilgar Posted September 24, 2009 Share Posted September 24, 2009 For $x = 1 to $aRecords[0] _FFConnect() If _FFIsConnected() Then _FFOpenUrl($x,$aRecords[$x]) Sleep(5000) Endif Next Have you looked after the console output from your editor? 1) First "problem" - you made in every loop a new connection to FireFox - one connection is enough. 2) The first parameter from _FFOpenURL is the URL - you have there an integer 3) The second parameter from _FFOpenURL is a boolean for $bLoadWait The last two things must you show many errors in the console. _FFOpenURL _FFConnect() If _FFIsConnected() Then For $x = 1 to $aRecords[0] _FFOpenUrl($aRecords[$x]) Sleep(5000) Next EndIf jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Kashgari Posted September 24, 2009 Author Share Posted September 24, 2009 Dear Stilgar, Thank you very much for your help. I have changed the code , but it still produces nothing. It runs, but no action. Link to comment Share on other sites More sharing options...
Stilgar Posted September 24, 2009 Share Posted September 24, 2009 Dear Stilgar,Thank you very much for your help.I have changed the code , but it still produces nothing.It runs, but no action.Are the URLs from your file really in this array?What is the output in your editor console? jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Kashgari Posted September 24, 2009 Author Share Posted September 24, 2009 What is the output in your editor console?Sorry I am still learning, I do not know how to use editor console. Are the URLs from your file really in this array?Yes, it is a simple text file with five lines, each line is one URL. Actually this test is working Msgbox(0,"", $aRecords[$x]) But when I change that line to _FFOpenUrl($aRecords[$x]) script does nothing. This is the whole code. #include <file.au3> #Include <FF.au3> Dim $aRecords If Not _FileReadToArray("url.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf _FFConnect() If _FFIsConnected() Then For $x = 1 to $aRecords[0] _FFOpenUrl($aRecords[$x]) Sleep(5000) Next EndIf Link to comment Share on other sites More sharing options...
Stilgar Posted September 24, 2009 Share Posted September 24, 2009 (edited) Sorry I am still learning, I do not know how to use editor console. Yes, it is a simple text file with five lines, each line is one URL. Actually this test is working Msgbox(0,"", $aRecords[$x]) But when I change that line to _FFOpenUrl($aRecords[$x]) script does nothing. This is the whole code. #include <file.au3> #Include <FF.au3> Dim $aRecords If Not _FileReadToArray("url.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf _FFConnect() If _FFIsConnected() Then For $x = 1 to $aRecords[0] _FFOpenUrl($aRecords[$x]) Sleep(5000) Next EndIf OK, but have you any error messages from the FF.au3 in the console of your editor? I think you can open it in SciTe with F8 - I don't use this editor. Is the connection to FireFox working? You can check it with: If _FFConnect() Then MsgBox(0,"", "Connected") Edited September 24, 2009 by Stilgar jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
Kashgari Posted September 24, 2009 Author Share Posted September 24, 2009 Dear Stilgar, Thank you very much for your attention. I got it worked. But something strange happened. For making thing faster instead of entering web url, I have made 5 pages, in my computer (I am on Xampp) to do the test such as http://localhost/test/file1.html http://localhost/test/file2.html ... I can visit these pages with no problem, but the script did not able to visit them, as soon as I have changed URL to online URLs it worked. Problem solved, but is it normal? 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