@lmstearn thank you , was playing to get a formatted text
Code: Select all
;- Help Getting innerText from Web Element
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=126230
;- FONT for notepad example Lucida Console
;-
F1:=a_desktop . "\test22.txt"
GetCountryInfo := "https://www.scrapethissite.com/pages/simple/"
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("GET", GetCountryInfo)
whr.Send()
WebRequest.WaitForResponse()
GetCountryInfo := whr.ResponseText
document := ComObjCreate("HTMLFile")
document.write(GetCountryInfo)
I:=0
if document.Url
{
e4x:="Country-Name;Capital;Population;Area`r`n--------;--------;-------;-----`r`n"
;msgbox, % document.getElementsByClassName("country-name")[1].innerText ;- 0=Andorra , 1=United arab Emirates
;loop,250
loop,10
{
u:= % document.getElementsByClassName("country-name")[i].innerText
v:= % document.getElementsByClassName("country-capital")[i].innerText
w:= % document.getElementsByClassName("country-population")[i].innerText
x:= % document.getElementsByClassName("country-area")[i].innerText
e4x .= u . "`;" . v . "`;" . w . "`;" . x . "`r`n"
i++
}
}
else
msgbox No URL for Document!
if e4x<>
{
filedelete,%f1%
NewCol := ColWidth(e4x)
fileappend,%newcol%,%f1%,utf-8
try,run,%f1%
}
Exitapp
;-----------------------------------------------------
;---- function linepadding formatx -------------------
;- https://www.autohotkey.com/boards/viewtopic.php?style=7&t=6815
ColWidth(e4x)
{
ColWidth =25,25,15,14
dlm:=";"
StringSplit,ColWidth_, ColWidth,`,
Loop, %ColWidth_0%
{
if (a_index=3 or a_index=4) ;- columns 3+4 to be right aligned
ResColumn .= "{:" ColWidth_%A_Index% "}" ((ColWidth_0 = A_Index) ? "" : dlm)
else
ResColumn .= "{:-" ColWidth_%A_Index% "}" ((ColWidth_0 = A_Index) ? "" : dlm)
}
Loop Parse, e4x, `n, `r
{
If StrLen(a_loopfield) < 1
Continue
a := StrSplit(a_loopfield,dlm)
NewLine .= Format( ResColumn . "|`r`n",a*)
;NewLine .= Format("{:-20}|{:-20}|{:-20}`n",a*)
}
Return NewLine
}
;======================================================
example output
Code: Select all
Country-Name ;Capital ; Population; Area|
-------- ;-------- ; -------; -----|
Andorra ;Andorra la Vella ; 84000; 468.0|
United Arab Emirates ;Abu Dhabi ; 4975593; 82880.0|
Afghanistan ;Kabul ; 29121286; 647500.0|
Antigua and Barbuda ;St. John's ; 86754; 443.0|
Anguilla ;The Valley ; 13254; 102.0|
Albania ;Tirana ; 2986952; 28748.0|
Armenia ;Yerevan ; 2968000; 29800.0|
Angola ;Luanda ; 13068161; 1246700.0|
Antarctica ;None ; 0; 1.4E7|
Argentina ;Buenos Aires ; 41343201; 2766890.0|