Re: getSelection in a screenscraper

From: Rickard Öberg <rickard.oberg_at_senselogic.se>
Date: Fri, 21 Oct 2005 12:42:59 +0200

Hey

Thanks for the idea to use getSelection()! I whipped up a generic scraper that allows you to show popup alerts saying things like "Select title", "Select date", etc. upon which the user selects the text in the document and then the scraper uses doc.getSelection() to get the data. Pretty nifty way to get data about a webpage in a very ad hoc kind of way. :-) Especially useful for scraping news stories from all around the world, all of which are in a different format but usually has all the required information on the page somewhere.

/Rickard

------ Original Message ------
From: Alf Eaton <lists_at_hubmed.org>
Date: Thursday, October 20th, 2005 8:43 PM CEST
To: general_at_simile.mit.edu
Subject: Re: getSelection in a screenscraper

That did the trick - I'd tried document, but not doc. I've updated my
Google Map scraper to work with the new Google Local format:
http://alf.hubmed.org/scrapers/

alf.

On 20 Oct 2005, at 07:04, David Huynh wrote:


> Could you try doc.getSelection() instead? The variable doc is the
> HTML document you're scraping. window on the other hand is probably
> the XUL chrome window of the browser, since your scraper code is
> running in the context of the Piggy Bank extension, not of the HTML
> document.
>
> David
>
> Alf Eaton wrote:
>
>
>
>> I'm trying to use window.getSelection() in a screenscraper, in
>> order to import selected text into Piggy Bank, but I'm having
>> trouble getting it to work.
>>
>> I can run
>> alert(window.getSelection().toString());
>> in a javascript shell and it works fine,
>> but if I do the same thing in a Piggy Bank scraper it shows up blank.
>>
>> My guess is that's it's something to do with the new
>> XPCNativeWrapper (this is Firefox 1.5b2) ... in Greasemonkey I'd
>> use unsafeWindow.getSelection(), but I'm not sure what the
>> equivalent is in Piggy Bank (I tried unsafeWin, but it was
>> undefined).
>>
>> alf.
>>
>>
>>
>
>
>
Received on Fri Oct 21 2005 - 10:37:38 EDT

This archive was generated by hypermail 2.3.0 : Thu Aug 09 2012 - 16:39:18 EDT