Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to get the selected text of the webpage in chrome through python ?

Reply
Thread Tools

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

 
 
iMath
Guest
Posts: n/a
 
      01-08-2013
How to get the selected text of the webpage in chrome through python ?
 
Reply With Quote
 
 
 
 
iMath
Guest
Posts: n/a
 
      01-08-2013
在 2013年1月8日星期二UTC+8下午12时20分28秒 ,iMath写道:
> How to get the selected text of the webpage in chrome through python ?


I need the code ,cuz I am only familiar with Python ,so it would be betterto give me the code written in Python .
You can also give me the code in other programming language ,thanks in advance
 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      01-08-2013
On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath <redstone->
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.
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
Dave Angel
Guest
Posts: n/a
 
      01-08-2013
On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote:
> On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath <redstone->
> 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/2...on-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

 
Reply With Quote
 
Bruno Dupuis
Guest
Posts: n/a
 
      01-08-2013
On Mon, Jan 07, 2013 at 08:20:28PM -0800, iMath wrote:
> How to get the selected text of the webpage in chrome through python ?


What you need is a way to get selected text from wherever it comes. The
way to do this depends on your graphical environment. If you use X, i'd make a
a quick and dirty call to xclip -o, although there must be a pure python
implementation which in turn depends on the python framework you play
with (gtk/qt/wx/tk/...).

Short answer is : it depends on your system, and it may be easier and more
portable if you use a graphical toolkit.

cheers.

--
Bruno Dupuis

 
Reply With Quote
 
Miki Tebeka
Guest
Posts: n/a
 
      01-08-2013
On Monday, January 7, 2013 8:20:28 PM UTC-8, iMath wrote:
> How to get the selected text of the webpage in chrome through python ?


You can probably use selenium to do that.
 
Reply With Quote
 
iMath
Guest
Posts: n/a
 
      01-09-2013
在 2013年1月8日星期二UTC+8下午9时19分51秒 Bruno Dupuis写道:
> On Mon, Jan 07, 2013 at 08:20:28PM -0800, iMath wrote:
>
> > How to get the selected text of the webpage in chrome through python ?

>
>
>
> What you need is a way to get selected text from wherever it comes. The
>
> way to do this depends on your graphical environment. If you use X, i'd make a
>
> a quick and dirty call to xclip -o, although there must be a pure python
>
> implementation which in turn depends on the python framework you play
>
> with (gtk/qt/wx/tk/...).
>
>
>
> Short answer is : it depends on your system, and it may be easier and more
>
> portable if you use a graphical toolkit.
>
>
>
> cheers.
>
>
>
> --
>
> Bruno Dupuis


I use it on WinXP , I also learned PyQt4 .
can u help ?
 
Reply With Quote
 
iMath
Guest
Posts: n/a
 
      01-09-2013
在 2013年1月8日星期二UTC+8下午9时19分51秒 Bruno Dupuis写道:
> On Mon, Jan 07, 2013 at 08:20:28PM -0800, iMath wrote:
>
> > How to get the selected text of the webpage in chrome through python ?

>
>
>
> What you need is a way to get selected text from wherever it comes. The
>
> way to do this depends on your graphical environment. If you use X, i'd make a
>
> a quick and dirty call to xclip -o, although there must be a pure python
>
> implementation which in turn depends on the python framework you play
>
> with (gtk/qt/wx/tk/...).
>
>
>
> Short answer is : it depends on your system, and it may be easier and more
>
> portable if you use a graphical toolkit.
>
>
>
> cheers.
>
>
>
> --
>
> Bruno Dupuis


I use it on WinXP , I also learned PyQt4 .
can u help ?
 
Reply With Quote
 
iMath
Guest
Posts: n/a
 
      01-09-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->

>
> > 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/2...on-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 .
 
Reply With Quote
 
iMath
Guest
Posts: n/a
 
      01-09-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->

>
> > 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/2...on-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 .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Google Chrome OS, Odds are stacked against Chrome OS's success Max Burke NZ Computing 1 07-11-2009 04:38 AM
textarea: get text left and right from selected text mariomueller Javascript 2 08-24-2006 04:49 AM
check if a webpage is forwarding to a other webpage martijn@gamecreators.nl Python 1 09-06-2005 02:27 PM
A tool to display current selected webpage's text css? John Dalberg HTML 9 04-25-2005 02:54 PM



Advertisments