Hi @all
wie kann ich die geöffnete Internetseite des Firefox auslesen
Ich hoffe jemand weis wie das geht
Hi @all
wie kann ich die geöffnete Internetseite des Firefox auslesen
Ich hoffe jemand weis wie das geht
Das musst Du wohl mit der UDF FF.au3 auslesen. Anders scheint es nicht zu gehen, da es sich hierbei um XUL-Controls handelt.
Was sind XUL-Controls
Ich schätze mal du willst das gar nicht wissen, man kann sie einfach nicht mit Autoit auslesen^^
Das sagt Wikipedia dazu: http://de.wikipedia.org/wiki/XML_User_Interface_Language
mfg
@OP:
Du wolltest sicher auch ne wirkliche Antwort ...
Mit der FF.au3 würde das so aussehen:
[autoit]
#include <FF.au3>
_FFConnect()
$sURL = _FFCmd(".location.href")
alles weitere dazu dort:
https://autoit.de/index.php?page=Board&boardID=32
Ich hab doch eh noch den Link zuder Erklärung auf Wikipedian Angehängt, na ja egal
Och das war doch nicht bös gemeint
Und auch nur allgemein so dahin gestellt.
Und wie wird es in der FF.au3 ausgelesen
@OP:
Du wolltest sicher auch ne wirkliche Antwort ...Mit der FF.au3 würde das so aussehen:
[autoit][/autoit] [autoit][/autoit] [autoit]
#include <FF.au3>_FFConnect()
[/autoit]
$sURL = _FFCmd(".location.href")alles weitere dazu dort:
https://autoit.de/index.php?page=Board&boardID=32
Augen auf mien Jung !
Ja aber ich meine wie FFCmd die seite ausliest also kein beispiel sondern es hat geheisen es geht mit autoit nicht aber ffcmd ist doch eine autoit funktion
Wie? Schau dir halt die UDF an
Oder Kurzversion:
Die FF.au3 arbeitet über eine Telnet-Schnittstelle in FF die durch das AddOn MozRepl realisiert ist und ermöglicht darüber den Zugriff auf gesamten Browser, nicht nur auf die dargestellte Seite.
Ok ich habe jezt mozrepl im ff instaliert und gestartet wie kann ich jetzt so einen befehl an ff senden mit autoit ? Ohne der FF.au3
Ohne der FF.au3? Bist du dir sicher?
Voraussetzungen:
* Erst mal die Anleitung zu MozRepl durchlesen
* HTML/JavaScript/DOM im Schlaf beherrschen
* XPath wäre auch nicht schlecht
* den Inhalt des MDN halbwegs überblicken: https://developer.mozilla.org/En
* die Sachen die dort nicht (offensichtlich) stehen, bekommt man aber auch durch das Zerlegen des Browser-Source-Codes heraus
Dann per AutoIt:
1 per TCP eine Verbindung zu MozRepl aufbauen
2 auf Antwort warten
3 Antwort auswerten
4 evtl. Fehler abfangen
5 Befehle in Form von JavaScript senden, dabei evtl. Wrapper für sicherheitkritische Sachen beachten
6 GOTO 2
evtl. dort die ersten Versuche ansehen:
FF-Management - FireFox.au3
FF-Management - FireFox.au3
Warum geht dann folgendes nicht
Global $Firefox_connect
_FirefoxConnect()
$sURL = _FirefoxCmd(".location.href")
MsgBox(0,"",$sURL)
Func _FirefoxConnect()
$IP = "127.0.0.1"
$iPort = 4242
TCPStartup()
[/autoit] [autoit][/autoit] [autoit]While 1
$Firefox_connect = TCPConnect($IP, $iPort)
WENd
IF $Firefox_connect <> -1 Then
If _FFWaitForRepl(10000) Then
ConsoleWrite("Browser is connected")
Endif
else
TCPShutdown()
endif
EndFunc
Func _FirefoxCmd($Firefox_command)
$Firefox_command = "window.content.wrappedJSObject.document" & $Firefox_command
_FirefoxSend($Firefox_command)
Endfunc
Func _FirefoxSend($sCommand)
TCPSend($Firefox_connect, $sCommand & @CRLF)
EndFunc
Wo kommt denn die Funktion "_FFWaitForRepl" her?
Du rufst die zwar auf, die ist aber nicht vorhanden.
Aus der Schleife:
[autoit]While 1
$Firefox_connect = TCPConnect($IP, $iPort)
WENd
Kommt das Programm nie wieder heraus.
Wenn du was gesendet hast, dann mußt du auch die Antwort von MozRepl auch abholen
"window.content.wrappedJSObject.document" ist nicht bei jeder Art von Befehl richtig.
Auf Frames bekommst du mit diesem Aufbau der Funktionen auch keinen Zugriff.
Wenn einen falschen JavaScript-Befehl abschickst, bringt MozRepl auch einen Fehler, den du wieder zurücksetzen muß, sonst geht gar nichts mehr, oder schickst eben ein try/catch mit.
Und vor allem - warum möchtest du die ganzen Funktionen denn neu bauen?
Um die FF.au3 besser zu verstehen und um zu lernen.
Wie muss ich es dann richtig machen ? bei der funktion habe ich einen unterstrich vergessen
Und wie komme ich aus der schleife wieder heraus?
Die While Schleife kannst du weglassen, entweder die Verbindung wird aufgebaut oder nicht.
Die Kommunikation und die eigentliche "Bedienung" von FF sind zwei vollkommen verschiedene Sachen.
Die Bedienung erfolgt rein über das Senden von JavaScript-Befehlen und die Kommunkation ist reines Telnet.
Also eins nach dem anderen
Schau dir mal das dort an:
FF-Management - FireFox.au3
das ein einfaches Telnet Programm, mit dem du direkt z.B. auf MozRepl zugreifen kannst, vielleicht wird die Kommunaktion damit klarer.
Das ganze Drumherum bei __FFWaitForRepl usw. ist nötig um die empfangenen Daten auszuwerten.
Wenn das alles funktioniert, kommen die eigentlichen Funktionen, wobei bei denen meistens 90% der Funktion aus einer Auwertung der Übergabeparameter besteht.
Was dann eigentlich an FF gesendet wird, kannst du (größtenteils zumindest) mit der neuen Testversion ausprobieren:
Neue Funktionen und ToDo-List
damit lassen sich die Befehle aufzeichnen die gesendet werden.
Aus einem:
[autoit]_FFSetValueByName("fname", "Vorname")
[/autoit]
wird dann im Endeffekt:
_FFCmd(".getElementsByName('fname')[0].value='Vorname';")
[/autoit]Ok danke
Wie muss ich folgendes umändern damit die url herauskommt
Global $Firefox_connect
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$socket = _FirefoxConnect()
[/autoit] [autoit][/autoit] [autoit]$sURL = _FirefoxCmd("content.frames[0].document.location.href")
MsgBox(0,"",$sURL)
Func _FirefoxConnect()
$IP = "127.0.0.1"
$iPort = 4242
TCPStartup()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$Firefox_connect = TCPConnect($IP, $iPort)
[/autoit] [autoit][/autoit] [autoit]IF $Firefox_connect <> -1 Then
If _FirefoxWait() Then
return $Firefox_connect
else
return -1
Endif
else
TCPShutdown()
endif
EndFunc
Func _FirefoxCmd($Firefox_command)
_FirefoxSend($Firefox_command)
$return = _FirefoxRecv()
Return $return
Endfunc
Func _FirefoxSend($sCommand)
TcpSend($Firefox_connect,$sCommand & @CRLF )
EndFunc
Func _FirefoxWait()
[/autoit] [autoit][/autoit] [autoit]Local $i = 0
Local $return = 1
While 1
$recv = TCPRecv($Firefox_connect,4096)
If @error Then
$return = 0
ExitLoop
Endif
If StringInStr($recv,"repl>") Then
ExitLoop
Endif
$i += 1
If $i > 10 Then
ExitLoop
Endif
WEnd
Return $return
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _FirefoxRecv()
Local $sRet = _FirefoxWait()
Return $sRet
EndFunc
So gehts:
Global $Firefox_connect
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If _FirefoxConnect() Then
Global $sURL = _FirefoxCmd("window.content.document.location.href")
MsgBox(0, "", $sURL)
EndIf
; ==============================================================================
Func _FirefoxConnect()
Local $IP = "127.0.0.1"
Local $iPort = 4242
TCPStartup()
[/autoit] [autoit][/autoit] [autoit]$Firefox_connect = TCPConnect($IP, $iPort)
[/autoit] [autoit][/autoit] [autoit]If $Firefox_connect <> -1 Then
If _FirefoxWait() Then
Return 1
Else
Return 0
EndIf
Else
TCPShutdown()
EndIf
EndFunc ;==>_FirefoxConnect
; ==============================================================================
Func _FirefoxCmd($Firefox_command)
_FirefoxSend($Firefox_command)
Return _FirefoxRecv()
EndFunc ;==>_FirefoxCmd
; ==============================================================================
Func _FirefoxSend($sCommand)
TCPSend($Firefox_connect, $sCommand & @CRLF)
EndFunc ;==>_FirefoxSend
; ==============================================================================
Func _FirefoxWait()
Local $sReturn = '', $recv
[/autoit] [autoit][/autoit] [autoit]Local $TimeOutTimer = TimerInit()
While TimerDiff($TimeOutTimer) < 5000
$recv = TCPRecv($Firefox_connect, 4096)
ConsoleWrite($recv)
If @error Then ExitLoop
$sReturn &= $recv
If StringRegExp($recv, "!!!(.*?)(TypeError|Exception|ReferenceError):?") Then
$recv = StringLeft($recv, StringInStr($recv, "location") - 1)
SetError(1)
Return ""
ElseIf StringInStr($recv, "....>") Then
_FirefoxSend(";") ; MozRepl-Reset
Sleep(100)
SetError(2)
Return ""
ElseIf StringInStr($recv, "beginning of the line to force evaluation") Then
Sleep(500) ; first connection delay
EndIf
If StringRegExp($recv, "repl[\d]?>") Then Return StringRegExpReplace($sReturn, "repl[\d]?>", "")
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit]Return ''
EndFunc ;==>_FirefoxWait
; ==============================================================================
Func _FirefoxRecv()
Local $sRet = _FirefoxWait()
$sRet = StringStripWS($sRet, 3) ; Leerzeichen entfernen
; Anführungszeichen am Anfang und Ende entfernen
If StringLeft($sRet, 1) = '"' Then $sRet = StringTrimLeft($sRet, 1)
If StringRight($sRet, 1) = '"' Then $sRet = StringTrimRight($sRet, 1)
Return $sRet
EndFunc ;==>_FirefoxRecv
Boaa cool danke stilgar , jezt habe ich es verstanden