Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Bestimmten Inhalt einer Webseite auslesen und in txt schreiben


  • Please log in to reply
22 replies to this topic
jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Auch das aktualisierte Script#2 zeigt das was in meim Screenshot zu sehen ist an o.O
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

text sieht bei mir so aus , d.h die Linie mit MDAX ist DAX

DAX
0,19%
7.848,57 MDAX
-0,48%
12.697,39 TecDAX
-1,54%
875,16 Euro Stoxx 50
0,17%
2.749,27 NASDAQ 100
0,04%
2.743,58 Dow Jones
0,52%
13.954,42

 

vielleicht ist bei Dir anders, kannst es kontrollieren , write mit fileappend zu text-file

;....
aas:
d = %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
GuiControl,,time,%d%

document:= pwb.Document
range := document.body.createTextRange()
aaa:=% range.Text
;msgbox,%aaa%
fileappend,%aaa%`r`n,Dax_pwb.txt
return



jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Bei diesem Script:
Spoiler


20130131091i0ke8vgsrz.jpg
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

Frage die Profis betreffend com oder andere Ideen

 

 

modified=20130201 /2
;-- http://www.autohotkey.com/board/topic/89509-bestimmten-inhalt-einer-webseite-auslesen-und-in-txt-schreiben/

; ===================================================================================
; AHK Version ...: ahk_L 1.1.09.02 ansi 32-bit
; Win Version ...: Windows XP netbook
; Script ........:
; Description ...:
; ===================================================================================

#Warn
#NoEnv
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%
DetectHiddenWindows, On
transform,S,chr,32

;URL=http://www.boerse-frankfurt.de/de/aktien/indizes/dax+DE0008469008
url=http://www.boerse-frankfurt.de/de/start
;run,%url%   ; for test

r1 = Right
r2 = Right%s%ReadOnly

;Gui, Show, w270 h205
Gui, Margin, 10, 10
Gui, Font, s10, Tahoma

Gui,Add,Edit,x0 y0 h0 w0 vEmpty

Gui, Add, Text, xm ym w100 %r1%, DAX
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vDAX,

Gui, Add, Text, xm yp+30 w100 %r1%, MDAX
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vMdax,

Gui, Add, Text, xm yp+30 w100 %r1%, TecDAX
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vtecdax,

Gui, Add, Text, xm yp+30 w100 %r1%, Euro Stoxx 50
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vEurostoxx,

Gui, Add, Text, xm yp+30 w100 %r1%, NASDAQ 100
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vNASDAQ,

Gui, Add, Text, xm yp+30 w100 %r1%, Dow Jones
Gui, Add, Edit, xm+130 yp-1 w100 h20 %r2% vDowJones,

Gui, Add, Text, xm+80 yp+30 w150 %r1% vTIME,
Gui, Show, w270 h205
GuiControl,Focus,empty

sleep,500
;-------------
pwb:= ComObjCreate("InternetExplorer.Application")
pwb.menuBar:=0,pwb.AddressBar:=0,pwb.StatusBar:=0,pwb.ToolBar:=0,pwb.width:="1000",pwb.height:="200"
;pwb.Visible := false ; <<< auf FALSE setzen, dann unsichtbar !!! oder eben TRUE dann sichtbar zur Kontrolle
pwb.Visible := true   ; <<< auf FALSE setzen, dann unsichtbar !!! oder eben TRUE dann sichtbar zur Kontrolle
ID:=pwb.HWND
winmove,ahk_id %ID%,,20,0,1000,200
pwb.Navigate(URL)

Loop
    {
    If pwb.readyState = 4
        break
    sleep 20
    }
;--------------
Gosub,aatime
Gosub,aas
SetTimer,aatime,1000
sleep,500
SetTimer,aas,2000
Return
;----------------------
GuiClose:
GuiEscape:
ComObjError(false)
pwb.Quit
exitapp
ExitApp
esc::exitapp

aatime:
d = %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
GuiControl,,time,%d%
return

/*
aaa=
(Ltrim Join`r`n
Willkommen

DAX
-0.47`%
7.811,31

MDAX
-0.47`%
12.618,70

TecDAX
-0.47`%
880,20

Euro Stoxx 50
-0.47`%
2.732,12

NASDAQ 100
-0.47`%
2.738,71

Dow Jones
-0.47`%
13.910,42
)
*/



aas:
document:= pwb.Document
range := document.body.createTextRange()
aaa:=% range.Text
;msgbox,%aaa%
;fileappend,%aaa%`r`n,Dax_pwb.txt
;return

found1=
i=0
Loop,Parse,aaa, `n,`r
{
lf=%a_loopfield%
aa:=substr(a_loopfield,1,3)
ab:=substr(a_loopfield,1,4)
ac:=substr(a_loopfield,1,6)

if (aa="dax")
  found1=dax
  if (found1="dax")
  {
  i++
  if (i=3)
     {
     GuiControl,,DAX, %lf%
     i=0
     found1=
     }
  else
    continue
  }

if (ab="mdax")
  found1=mdax
  if (found1="mdax")
  {
  i++
  if (i=3)
     {
     GuiControl,,MDAX,%lf%
     i=0
     found1=
     }
  else
    continue
  }


if (ac="Tecdax")
  found1=tecdax
  if (found1="tecdax")
  {
  i++
  if (i=3)
     {
     GuiControl,,TECDAX,%lf%
     i=0
     found1=
     }
  else
    continue
  }


If lf contains Euro Stoxx 50       ;-- eurostoxx
  found1=EuroStoxx
  if (found1="EuroStoxx")
  {
  i++
  if (i=3)
     {
     GuiControl,,Eurostoxx,%lf%
     i=0
     found1=
     }
  else
    continue
  }

If lf contains NASDAQ 100       ;-- nasdaq
  found1=nasdaq
  if (found1="nasdaq")
  {
  i++
  if (i=3)
     {
     GuiControl,,Nasdaq,%lf%
     i=0
     found1=
     }
  else
    continue
  }

If lf contains Dow Jones       ;-- Dow Jones
  found1=DowJones
  if (found1="DowJones")
  {
  i++
  if (i=3)
     {
     GuiControl,,DowJones,%lf%
     i=0
     found1=
     break
     }
  else
    continue
  }
}
Return
;====================== end script ====================================================







jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Zum 1.
Dax           | Dax
7.811,31      | 7.811,31

MDAX          | DAX             Fehler
12.618,70     | 12.618,70 

TecDax        | DAX             Fehler
880,20        | 880,20

Euro Stoxx 50 | Eurostoxx
2.732,12      | 2.732,12 

NASDAQ 100    | NESDAQ
2.738,71      | 2.738,71 

Dow Jones     | DownJones
13.910,42     | 13.910,42
Spoiler



Zum 2.
07d4a6bwuyeo.jpg
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

Testscript und script oben korrigiert

sollte man besser machen  ...

 

mal ein Test-Foto

( wobei bei mir anders ist )

dax19suw0htbe.jpg

 

 

anbei korrigierter Testscript

im Prinzip ist

IfInString,A_LoopField,dax

falsch , da es nicht weiss ob es DAX oder Mdax oder TecDax  ist

 

  

;-------- saved at Freitag, 1. Februar 2013 12:07:45 --------------
;-------- http://www.autohotkey.com/board/topic/89509-bestimmten-inhalt-einer-webseite-auslesen-und-in-txt-schreiben/page-2 ---
aaa=
(Ltrim Join`r`n
Willkommen

DAX
-0.47`%
7.811,31

MDAX
-0.47`%
12.618,70

TecDAX
-0.47`%
880,20

Euro Stoxx 50
-0.47`%
2.732,12

NASDAQ 100
-0.47`%
2.738,71

Dow Jones
-0.47`%
13.910,42
)


found1=
i=0
Loop,Parse,aaa, `n,`r
{
aa:=substr(a_loopfield,1,3)
ab:=substr(a_loopfield,1,4)
ac:=substr(a_loopfield,1,6)

if (aa="dax")
  found1=dax
  if (found1="dax")
  {
  i++
  if (i=3)
     {
     msgbox,DAX= %a_loopfield%
     i=0
     found1=
     }
  else
    continue
  }

if (ab="mdax")
  found1=mdax
  if (found1="mdax")
  {
  i++
  if (i=3)
     {
     msgbox,MDAX=%a_loopfield%
     i=0
     found1=
     }
  else
    continue
  }


if (ac="Tecdax")
  found1=tecdax
  if (found1="tecdax")
  {
  i++
  if (i=3)
     {
     msgbox,TECDAX=%a_loopfield%
     i=0
     found1=
     }
  else
    continue
  }


If A_LoopField contains Euro Stoxx 50       ;-- eurostoxx
  found1=EuroStoxx
  if (found1="EuroStoxx")
  {
  i++
  if (i=3)
     {
     msgbox,Eurostoxx= %a_loopfield%
     i=0
     found1=
     }
  else
    continue
  }

If A_LoopField contains NASDAQ 100       ;-- nasdaq
  found1=nasdaq
  if (found1="nasdaq")
  {
  i++
  if (i=3)
     {
     msgbox,Nasdaq= %a_loopfield%
     i=0
     found1=
     }
  else
    continue
  }

If A_LoopField contains Dow Jones       ;-- Dow Jones
  found1=DowJones
  if (found1="DowJones")
  {
  i++
  if (i=3)
     {
     msgbox,DowJones=%a_loopfield%
     i=0
     found1=
     break
     }
  else
    continue
  }
}
exitapp
return
esc::exitapp
;-------------------------------------------------



jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
Soweit schon mal ein riesen Dank garry

Spoiler

 
Das letzte Problem ist, das er trotz ( r2 = Right ReadOnly ) nicht rechtsbündig schreibt
20130201142rhd0lj873n.jpg
[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

ob es noch spaces hat nach der Zahl ?

(bei mir funktioniert , ich erhalte anderen Text)

habe script oben korrigiert

lf=%a_loopfield%    ;<< -- zuerst im loop ,  danach a_loopfield mit LF ersetzt ( könnte Leerzeichen löschen )

 

transform,S,chr,32
r2 = Right%s%ReadOnly      ;<< space erzwungen

 

vielen Dank für alle user , SAPlayer ,nnik, gero   ( script oben von gero)

und falls site ändert funktioniert wieder nicht ....