Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web Image saving
#15
Get all img src:
Macro Macro1644
Code:
Copy      Help
int w=wait(2 WV win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804))
Acc a1.Find(w "DOCUMENT" "" "" 0x3010 2)
str s
a1.WebPageProp(0 0 s)
;out s

int i
HtmlDoc d.InitFromText(s)
ARRAY(MSHTML.IHTMLElement) a
d.GetHtmlElements(a "img")
for i 0 a.len
,MSHTML.IHTMLElement e=a[i]
,s=e.getAttribute("src" 0)
,out s

Another very similar way:
Macro Macro1645
Code:
Copy      Help
int w=wait(2 WV win("Mozilla Firefox" "Mozilla*WindowClass" "" 0x804))
Acc a1.Find(w "DOCUMENT" "" "" 0x3010 2)
str s
a1.WebPageProp(s)
;out s

int i
HtmlDoc d.InitFromWeb(s)
ARRAY(MSHTML.IHTMLElement) a
d.GetHtmlElements(a "img")
for i 0 a.len
,MSHTML.IHTMLElement e=a[i]
,s=e.getAttribute("src" 0)
,out s

In both cases, URLs are relative, with "about:" prefix.

To get all from selection:
Macro Macro1642
Trigger F8     Help - how to add the trigger to the macro
Code:
Copy      Help
str s.getsel(0 "HTML Format")
;out s
int i=find(s "<html" 0 1); if(i<0) ret
s.get(s i)
;out s

HtmlDoc d.InitFromText(s)
ARRAY(MSHTML.IHTMLElement) a
d.GetHtmlElements(a "img")
for i 0 a.len
,MSHTML.IHTMLElement e=a[i]
,s=e.getAttribute("src" 0)
,out s

URLs are full.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)