How to get the selected text of the webpage in chrome through python ?

iMath redstone-cold at 163.com
Tue Jan 8 21:54:06 EST 2013


在 2013年1月8日星期二UTC+8下午9时11分30秒,Dave Angel写道:
> On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote:
> 
> > On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath <redstone-cold at 163.com>
> 
> > 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

It seems need Javascript to work it on .
Unfortunately ,I am only familiar with python .



More information about the Python-list mailing list