Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get URI

19 views
Skip to first unread message

ista...@gmail.com

unread,
Apr 18, 2013, 8:35:15 AM4/18/13
to
Hi all:

Pretty basic question but: from a toolbar button click event (inside chrome folder) how do you get the URI of the current page and then ...

I can't get the URI of the current page and from there I will scrape info from the page using DOM.
THANKS FOR YOUR HELP!!
--Phil Dickson

Neil

unread,
Apr 18, 2013, 11:59:13 AM4/18/13
to
ista...@gmail.com wrote:

>Hi all:
>
>Pretty basic question but: from a toolbar button click event (inside chrome folder) how do you get the URI of the current page and then ...
>
>I can't get the URI of the current page and from there I will scrape info from the page using DOM.
>
If you're writing a traditional extension then you can use
content.location.href for example.

--
Warning: May contain traces of nuts.

ista...@gmail.com

unread,
Apr 20, 2013, 11:09:12 PM4/20/13
to
Right on the mark, Neil, Thanks!

Phil Dickson

unread,
Apr 25, 2013, 3:20:52 PM4/25/13
to
Can someone help me solve this (and save me alot of time). Problem:
push button to scrape element values from stock market page and copy
the info to the clipboard. The info is pasted to a database and
parsed etc.

I am using the function below to (hopefully) convert HTML page into
DOM and extract attribute values from the DOM elements <div>'s etc.
The function comes from https://developer.mozilla.org/en-US/docs/Code_snippets/HTML_to_DOM.

Example of the page I am looking at is to extract info is:
http://finance.yahoo.com/q?s=GTN&ql=1 ( searching like
getElementById("yfs_l84_gtn") )



function HTMLParser(aHTMLString){
var html = document.implementation.createDocument("http://www.w3.org/
1999/xhtml", "html", null),
body = document.createElementNS ("http://www.w3.org/1999/xhtml",
"body");
html.documentElement.appendChild(body);

body.appendChild(Components.classes["@mozilla.org/feed-unescapehtml;
1"]
.getService(Components.interfaces.nsIScriptableUnescapeHTML)
.parseFragment(aHTMLString, false, null, body));
return html;
}
Thanks for any help provided
Phil Dickson
0 new messages