Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python,': 0.02; 'subject:text': 0.05; 'differently': 0.07; 'subject:How': 0.09; 'python': 0.09; 'accepts': 0.09; 'subject:python': 0.11; 'suggest': 0.11; 'subject: \n ': 0.16; 'subject:through': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'copied': 0.17; 'jan': 0.18; 'equivalent': 0.20; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'realize': 0.27; 'start,': 0.27; 'probably': 0.29; 'returned': 0.30; 'subject: ?': 0.30; 'function': 0.30; 'to:addr:python-list': 0.33; 'text': 0.34; 'something': 0.35; 'quite': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'hints': 0.65; 'webpage': 0.65; 'header:Reply-To:1': 0.68; 'skip:n 30': 0.69; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'subject:get': 0.81; '2013': 0.84; 'addon': 0.84; 'not...': 0.84; 'received:74.208.4.194': 0.84; 'selection,': 0.84; 'dennis': 0.91 Date: Tue, 08 Jan 2013 08:11:30 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How to get the selected text of the webpage in chrome through python ? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:8e2HoqjDByNibw2msBUrf48XgLNOudPAxHT8X78esyP uxz7oqQbykzevRPhLpxER39LsMbrzoeNgtUFZaTM9qemllbyJS TK+1VnYyDW3axfnmNcHPFMzhWAE8B5JJ7I+864Vp2DYk0JxefB 4DN0SHdBR+arqwOEYe1QIDlt+/j6mKwEzw2AiSlbQt+9m2RYOL 1eaiu5g2wE0zXp3N9yCTjoMXni21NVypKra2kUBfveqHM6xmQn /2JWcEa7BFIlIvEWcJZPbiGSIhta5SxXHMQS+bIAZWGvRYn3/U 2cL+4Rwjr6cLeiGhomAWTUsWw6cqpfjrKBP7kYCWzPF3Yp03A= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357650704 news.xs4all.nl 6871 [2001:888:2000:d::a6]:47431 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36428 On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote: > On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath > declaimed the following in gmane.comp.python.general: > >> How to get the selected text of the webpage in chrome through python ? > Chrome is a browser, is it not... If you want to get the text in > Python, you have to write the equivalent of a browser -- something that > parses the returned HTML message, extracting the parts you want. To get a selection, you can either wait till it's copied to the clipboard, and get it from there, or you can write a addon for the application. Since Chrome accepts addons, I suggest you research that angle. Probably mozilla.org is the place to start, and function nsISelectionController::GetSelection() might be some place to examine. You might find some hints in http://stackoverflow.com/questions/2671474/range-selection-and-mozilla if you are going to work with the clipboard, realize that it works quite differently from one OS to another, and even from one desktop manager to another. -- DaveA