2009-11-08 4 views
2

J'ai besoin d'automatiser la navigation autour d'un site Web alimenté par JavaScript en Python afin de pouvoir récupérer du contenu. Je suis tombé sur Chickenfoot, qui est une extension FireFox qui me donne une interface de programmation au navigateur.automatiser la navigation d'un site Web alimenté par JavaScript

Connaissez-vous d'autres solutions?

+1

+1 pour m'avoir présenté à Chickenfoot –

Répondre

3

WWW::Mechanize a plusieurs extensions/remplacement compatibles pour gérer JavaScript: WWW :: :: Mechanize FireFox, WWW :: mécaniser :: Plugin :: JavaScript/WWW :: Scripter :: Plugin :: JavaScript, Mozilla :: Mechanize, Gtk2 :: WebKit :: Mécaniser, Win32 :: IE :: Mécaniser.

+0

Existe-t-il un équivalent Python? – hoju

2

Vous pouvez automatiser Internet Explorer assez facilement soit de javascript (.js) ou toute autre langue qui peut utiliser COM (C#, Perl, etc.)

http://msdn.microsoft.com/en-us/library/aa752084%28VS.85%29.aspx

Exemple simple dans vbscript:

Dim objIE 
Dim objWebForm 
Dim objDoc 
dim leCount 
dim objElement 
dim objElementCollection 
dim leIndex 

Set objIE = WScript.CreateObject("InternetExplorer.Application") 
objIE.AddressBar = true 
objIE.Visible = true 

Sub WaitForLoad (objIE) 
    Do While objIE.Busy 
    WScript.Sleep(1000) 
    Loop 
    WScript.Sleep(500) 
End Sub 

objIE.Navigate("http://www.softtesting.org/") 
WaitForLoad(objIE) 
set objDoc = objIE.document 

Set objElementCollection = objDoc.getElementsByTagName("a") 
leCount = objElementCollection.length 
For leIndex = 0 To leCount-1 
    Set objElement = objElementCollection(leIndex) 
    If (("http://www.softtesting.org/forum/")=objElement.href) Then 
     objElement.Click() 
    End If 
Next 

http://social.msdn.microsoft.com/Forums/en-US/windowsaccessibilityandautomation/thread/6c47aaec-6beb-4b21-95b2-95186f5bb4a5

+0

malheureusement, je suis sur Linux ... semble bien – hoju

0

check http://watin.org/ c'est comme chickenf oot, mais il supporte aussi ie. Et c'est gratuit.

Questions connexes