Sign in to follow this  
Followers 0
Kashgari

Firefox URL into Array

11 posts in this topic

#1 ·  Posted (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 by Kashgari

Share this post


Link to post
Share on other sites



This udf by Stilgar is what you are looking for.

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Thanks for your reply. I got it already.

What I am looking for is a script which can do the task I have asked.

Share this post


Link to post
Share on other sites

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.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Dear Stilgar,

Thank you very much for your help.

I have changed the code , but it still produces nothing.

It runs, but no action.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by Stilgar

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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
Sign in to follow this  
Followers 0