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

I

iMath

在 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 :)
 
D

Dennis Lee Bieber

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.
 
D

Dave Angel

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.
 
B

Bruno Dupuis

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.
 
I

iMath

在 2013å¹´1月8日星期二UTC+8下åˆ9æ—¶19分51秒,Bruno Dupuis写é“:
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.

I use it on WinXP , I also learned PyQt4 .
can u help ?
 
I

iMath

在 2013å¹´1月8日星期二UTC+8下åˆ9æ—¶19分51秒,Bruno Dupuis写é“:
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.

I use it on WinXP , I also learned PyQt4 .
can u help ?
 
I

iMath

在 2013å¹´1月8日星期二UTC+8下åˆ9æ—¶11分30秒,Dave Angel写é“:
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 .
 
I

iMath

在 2013å¹´1月8日星期二UTC+8下åˆ9æ—¶11分30秒,Dave Angel写é“:
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 .
 
I

iMath

在 2013å¹´1月9日星期三UTC+8下åˆ5æ—¶35分15秒,Alister写é“:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top