Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36409 > unrolled thread

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

Started byiMath <redstone-cold@163.com>
First post2013-01-07 20:20 -0800
Last post2013-01-09 17:55 -0800
Articles 12 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-07 20:20 -0800
    Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-08 02:52 -0800
    Re: How to get the selected text of the webpage in chrome through python ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-08 07:38 -0500
    Re: How to get the selected text of the webpage in chrome through python ? Dave Angel <d@davea.name> - 2013-01-08 08:11 -0500
      Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-08 18:54 -0800
      Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-08 18:54 -0800
    Re: How to get the selected text of the webpage in chrome through python ? Bruno Dupuis <lisael@lisael.org> - 2013-01-08 14:19 +0100
      Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-08 18:47 -0800
      Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-08 18:47 -0800
    Re: How to get the selected text of the webpage in chrome through python ? Miki Tebeka <miki.tebeka@gmail.com> - 2013-01-08 06:01 -0800
    Re: How to get the selected text of the webpage in chrome through python ? Alister <alister.ware@ntlworld.com> - 2013-01-09 09:35 +0000
      Re: How to get the selected text of the webpage in chrome through python ? iMath <redstone-cold@163.com> - 2013-01-09 17:55 -0800

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

FromiMath <redstone-cold@163.com>
Date2013-01-07 20:20 -0800
SubjectHow to get the selected text of the webpage in chrome through python ?
Message-ID<b181f61b-c5c9-461a-9acc-8c79e257fae7@googlegroups.com>
How to get the selected text of the webpage in chrome through python ?

[toc] | [next] | [standalone]


#36424

FromiMath <redstone-cold@163.com>
Date2013-01-08 02:52 -0800
Message-ID<52c801cb-8ca6-4044-b9a7-b8d15e3c1a0c@googlegroups.com>
In reply to#36409
在 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 better to give me the code written in Python .
You can also give me the code in other programming language   ,thanks in advance :)

[toc] | [prev] | [next] | [standalone]


#36425

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-01-08 07:38 -0500
Message-ID<mailman.270.1357648682.2939.python-list@python.org>
In reply to#36409
On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath <redstone-cold@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.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#36428

FromDave Angel <d@davea.name>
Date2013-01-08 08:11 -0500
Message-ID<mailman.273.1357650704.2939.python-list@python.org>
In reply to#36409
On 01/08/2013 07:38 AM, Dennis Lee Bieber wrote:
> On Mon, 7 Jan 2013 20:20:28 -0800 (PST), iMath <redstone-cold@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

[toc] | [prev] | [next] | [standalone]


#36468

FromiMath <redstone-cold@163.com>
Date2013-01-08 18:54 -0800
Message-ID<a9e9723f-b2d0-4810-81bd-1ba1093d577a@googlegroups.com>
In reply to#36428
在 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@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 .

[toc] | [prev] | [next] | [standalone]


#36470

FromiMath <redstone-cold@163.com>
Date2013-01-08 18:54 -0800
Message-ID<mailman.304.1357700573.2939.python-list@python.org>
In reply to#36428
在 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@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 .

[toc] | [prev] | [next] | [standalone]


#36429

FromBruno Dupuis <lisael@lisael.org>
Date2013-01-08 14:19 +0100
Message-ID<mailman.274.1357651549.2939.python-list@python.org>
In reply to#36409
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

[toc] | [prev] | [next] | [standalone]


#36466

FromiMath <redstone-cold@163.com>
Date2013-01-08 18:47 -0800
Message-ID<b53afd60-30b8-4c0a-b176-563378bc270f@googlegroups.com>
In reply to#36429
在 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 ?

[toc] | [prev] | [next] | [standalone]


#36467

FromiMath <redstone-cold@163.com>
Date2013-01-08 18:47 -0800
Message-ID<mailman.303.1357699629.2939.python-list@python.org>
In reply to#36429
在 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 ?

[toc] | [prev] | [next] | [standalone]


#36431

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2013-01-08 06:01 -0800
Message-ID<0a37e6da-be0c-400f-8174-00d47dadd4ab@googlegroups.com>
In reply to#36409
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.

[toc] | [prev] | [next] | [standalone]


#36482

FromAlister <alister.ware@ntlworld.com>
Date2013-01-09 09:35 +0000
Message-ID<nRaHs.1045$Ti6.922@fx15.fr7>
In reply to#36409
On Mon, 07 Jan 2013 20:20:28 -0800, iMath wrote:

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

i think you need to explain your  requirement further
also what do you want to do to the text once you have it?




-- 
Genius is one percent inspiration and ninety-nine percent perspiration.
		-- Thomas Alva Edison

[toc] | [prev] | [next] | [standalone]


#36543

FromiMath <redstone-cold@163.com>
Date2013-01-09 17:55 -0800
Message-ID<c9f69a1b-e833-40fb-8d59-6989342b07f3@googlegroups.com>
In reply to#36482
在 2013年1月9日星期三UTC+8下午5时35分15秒,Alister写道:
> On Mon, 07 Jan 2013 20:20:28 -0800, iMath wrote:
> 
> 
> 
> > How to get the selected text of the webpage in chrome through python ?
> 
> 
> 
> i think you need to explain your  requirement further
> 
> also what do you want to do to the text once you have it?
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Genius is one percent inspiration and ninety-nine percent perspiration.
> 
> 		-- Thomas Alva Edison

I want to google it with a mouse gesture

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web