AutoHotkey Community

It is currently May 27th, 2012, 1:10 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: January 6th, 2010, 9:47 pm 
Offline

Joined: October 28th, 2009, 10:01 pm
Posts: 21
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2010, 10:16 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
JavaScript maybe, but COM won't do you any good for this particular task unless you plan on using Internet Explorer.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2010, 11:52 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 5:41 am 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 8:18 am 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 6:18 pm 
Offline

Joined: May 10th, 2009, 7:30 pm
Posts: 45
I've never tried it but it would be cleaner to get the src attribute instead of the innerhtml.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 8:22 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 9:01 pm 
Offline

Joined: October 28th, 2009, 10:01 pm
Posts: 21
I am looking at the iWeb function. Is that only for IE or application with normal COM interface?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 9:17 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
IE only, yes.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 10:47 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
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

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Ohnitiel and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group