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

Discussion in 'Python' started by iMath, Jan 8, 2013.

  1. iMath

    iMath Guest

    How to get the selected text of the webpage in chrome through python ?
    iMath, Jan 8, 2013
    #1
    1. Advertising

  2. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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 :)
    iMath, Jan 8, 2013
    #2
    1. Advertising

  3. Re: How to get the selected text of the webpage in chrome throughpython ?

    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.
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Jan 8, 2013
    #3
  4. iMath

    Dave Angel Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    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
    Dave Angel, Jan 8, 2013
    #4
  5. iMath

    Bruno Dupuis Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    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
    Bruno Dupuis, Jan 8, 2013
    #5
  6. iMath

    Miki Tebeka Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    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.
    Miki Tebeka, Jan 8, 2013
    #6
  7. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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 ?
    iMath, Jan 9, 2013
    #7
  8. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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 ?
    iMath, Jan 9, 2013
    #8
  9. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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 <>

    >
    > > 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 .
    iMath, Jan 9, 2013
    #9
  10. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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 <>

    >
    > > 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 .
    iMath, Jan 9, 2013
    #10
  11. iMath

    iMath Guest

    Re: How to get the selected text of the webpage in chrome throughpython ?

    在 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
    iMath, Jan 10, 2013
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Dalberg
    Replies:
    9
    Views:
    519
    John Dalberg
    Apr 25, 2005
  2. He Jibo
    Replies:
    3
    Views:
    1,013
    Tim Harig
    Nov 29, 2010
  3. mariomueller
    Replies:
    2
    Views:
    551
    mariomueller
    Aug 24, 2006
  4. albert kao
    Replies:
    4
    Views:
    176
  5. me
    Replies:
    22
    Views:
    1,737
Loading...

Share This Page