| View previous topic :: View next topic |
| Author |
Message |
bonniehandi
Joined: 28 Oct 2009 Posts: 21
|
Posted: Wed Jan 06, 2010 8:47 pm Post subject: Retrieving image url from firefox - idea check |
|
|
Hello All,
I just want to run the idea by you experts before I go all in and realize that I have gone about it all wrong.
Here is the goal: I have a webpage with some pictures, and I want a list of the url of only those pictures that are from www.tinypic.com (that is on that page).
How I plan to do it:
1. With the help of COM with Javascript, use the innerHTML method to fetch the html of the page
2. Find all phases that matche "http://www.tinypic.com/*.jpg" using regular expression.
3. Open a notepad and paste those phases. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Jan 06, 2010 9:16 pm Post subject: |
|
|
JavaScript maybe, but COM won't do you any good for this particular task unless you plan on using Internet Explorer. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Murp|e
Joined: 12 Jan 2007 Posts: 531 Location: Norway
|
Posted: Wed Jan 06, 2010 10:52 pm Post subject: |
|
|
| Quote: | | 1. With the help of COM with Javascript, use the innerHTML method to fetch the html of the page |
Not sure, but you may find some of this useful:
urldownloadtovar
http://www.regular-expressions.info/examples.html :
| Quote: | Grabbing HTML Tags
<TAG\b[^>]*>(.*?)</TAG> matches the opening and closing pair of a specific HTML tag. Anything between the tags is captured into the first backreference. The question mark in the regex makes the star lazy, to make sure it stops before the first closing tag rather than before the last, like a greedy star would do. This regex will not properly match tags nested inside themselves, like in <TAG>one<TAG>two</TAG>one</TAG>.
<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1> will match the opening and closing pair of any HTML tag. Be sure to turn off case sensitivity. The key in this solution is the use of the backreference \1 in the regex. Anything between the tags is captured into the second backreference. This solution will also not match tags nested in themselves. |
|
|
| Back to top |
|
 |
Michael@Oz
Joined: 08 Nov 2009 Posts: 233 Location: Canberra Oz
|
Posted: Thu Jan 07, 2010 4:41 am Post subject: |
|
|
You could send a ^L to goto the url bar, which also selects the text.
Then ^c copy to clipboard and use the url to URLDownLoadToFile (or ...ToVar). Then process the results as you suggested. |
|
| Back to top |
|
 |
Murp|e
Joined: 12 Jan 2007 Posts: 531 Location: Norway
|
Posted: Thu Jan 07, 2010 7:18 am Post subject: |
|
|
| Quote: | | 3. Open a notepad and paste those phases |
A better solution would be to use fileappend to write the URLs to a text file and then doing | Code: | | run, notepad.exe TinyPictureList.txt |
|
|
| Back to top |
|
 |
JohnnyTwoTone
Joined: 10 May 2009 Posts: 45
|
Posted: Thu Jan 07, 2010 5:18 pm Post subject: |
|
|
| I've never tried it but it would be cleaner to get the src attribute instead of the innerhtml. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Thu Jan 07, 2010 7:22 pm Post subject: |
|
|
| JohnnyTwoTone wrote: | | I've never tried it but it would be cleaner to get the src attribute instead of the innerhtml. |
Here's an example using iWeb functions and a couple of my own custom functions:
| Code: | iWeb_Init()
pwb:=iWeb_getWin("New Images - TinyPic - Free Image Hosting, Photo Sharing & Video Hosting") ; http://tinypic.com/images.php
COM_Error(0)
Loop % iWeb_getTagLen(pwb,"img") {
if !InStr(iWeb_getTagObj(pwb,"img",A_Index-1,-1,-1,"src"),"tinypic.com")
continue
res.=((A_Index=1) ? "" : "`n") iWeb_getTagObj(pwb,"img",A_Index-1,-1,-1,"src")
}
iWeb_Release(pwb)
iWeb_Term()
MsgBox % res
return
iWeb_getTagLen(pdsp,tag,t="-1",r="-1",frm="") {
If pWin:=iWeb_DomWin(pdsp,frm) result:=COM_Invoke(pWin,"document.all.tags[" tag "]"
. ((tag="table" && t>=0) ? ".item[" t "].rows" : "") ((tag="table" && r>=0) ? "[" r "].cells" : "")
. ".length")
COM_Release(pWin)
return result
}
iWeb_getTagObj(pdsp,tag,itm,r="-1",c="-1",type="innerText",frm="") {
If pWin:=iWeb_DomWin(pdsp,frm)
result:=COM_Invoke(pWin,"document.all.tags[" tag "].item[" itm "]"
. ((tag="table" && r>=0) ? ".rows[" r "]" : "") ((tag="table" && c>=0) ? ".cells[" c "]" : "")
. "." type)
COM_Release(pWin)
return result
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
bonniehandi
Joined: 28 Oct 2009 Posts: 21
|
Posted: Thu Jan 07, 2010 8:01 pm Post subject: |
|
|
| I am looking at the iWeb function. Is that only for IE or application with normal COM interface? |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Thu Jan 07, 2010 9:47 pm Post subject: |
|
|
while iweb was written around IE it is important to note most functions rely on a pwb or iWebBrowser2 interface. so if you are using another browser based on IE (yes there are lots) that has a iWebBrowser2 interface any related functions should work unles explicitly disabled by that specific browser.
This means if you can create a pointer you can use iweb_setdomobj etc or return the url via com_invoke(pwb,"locationurl"). this is because of the concept of an interface is not application specific. That said there is no known support for this within firefox but you can look up Seans DDE functions on this forum to get that _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
|