From 1996a9d05c843f54eacda9c90ecaffaf446cf6d7 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 25 Feb 2018 08:17:34 -0500 Subject: [PATCH 1/4] Update README.rst --- README.rst | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index a650ebc..ce72fc6 100644 --- a/README.rst +++ b/README.rst @@ -26,14 +26,18 @@ Usage >>> r = session.get('https://python.org/') + # Grab a list of all links on the page (anchors excluded). >>> r.html.links {'/users/membership/', '/about/gettingstarted/', 'http://feedproxy.google.com/~r/PythonInsider/~3/zVC80sq9s00/python-364-is-now-available.html', '/about/success/', 'http://flask.pocoo.org/', 'http://www.djangoproject.com/', '/blogs/', ... '/psf-landing/', 'https://wiki.python.org/moin/PythonBooks'} + # Grab a list of all links on the page, in absolute form (anchors excluded). >>> r.html.absolute_links {'http://feedproxy.google.com/~r/PythonInsider/~3/zVC80sq9s00/python-364-is-now-available.html', 'https://www.python.org/downloads/mac-osx/', 'http://flask.pocoo.org/', 'https://www.python.org//docs.python.org/3/tutorial/', 'http://www.djangoproject.com/', 'https://wiki.python.org/moin/BeginnersGuide', 'https://www.python.org//docs.python.org/3/tutorial/controlflow.html#defining-functions', 'https://www.python.org/about/success/', 'http://twitter.com/ThePSF', 'https://www.python.org/events/python-user-group/634/', ..., 'https://wiki.python.org/moin/PythonBooks'} + # Select an element with a jQuery selector. >>> about = r.html.find('#about')[0] + # Grab an element's text contents. >>> print(about.text) About Applications @@ -42,6 +46,15 @@ Usage Help Python Brochure + # Introspect an Element's attributes. + >>> about.attrs + {'id': 'about', 'class': 'tier-1 element-1 ', 'aria-haspopup': 'true'} + + # Select Elements within Elements. + >>> about.find('a') + [, , , , , ] + + # Render an Element as Markdown. >>> print(about.markdown) * [About](/about/) @@ -51,13 +64,7 @@ Usage * [Getting Started](/about/gettingstarted/) * [Help](/about/help/) * [Python Brochure](http://brochure.getpython.info/) - - >>> about.attrs - {'id': 'about', 'class': 'tier-1 element-1 ', 'aria-haspopup': 'true'} - - >>> about.find('a') - [, , , , , ] - + >>> r.html.search('Python is a {} language')[0] programming From 4fc72e7a63ed2a77979b59a049ac3f7ede63772f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 25 Feb 2018 08:19:38 -0500 Subject: [PATCH 2/4] Update README.rst --- README.rst | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index ce72fc6..81d6cb4 100644 --- a/README.rst +++ b/README.rst @@ -22,22 +22,35 @@ Usage .. code-block:: pycon - >>> from requests_html import session +Make a GET request to python.org: + >>> from requests_html import session >>> r = session.get('https://python.org/') - # Grab a list of all links on the page (anchors excluded). +Grab a list of all links on the page (anchors excluded): + +.. code-block:: pycon + >>> r.html.links {'/users/membership/', '/about/gettingstarted/', 'http://feedproxy.google.com/~r/PythonInsider/~3/zVC80sq9s00/python-364-is-now-available.html', '/about/success/', 'http://flask.pocoo.org/', 'http://www.djangoproject.com/', '/blogs/', ... '/psf-landing/', 'https://wiki.python.org/moin/PythonBooks'} - # Grab a list of all links on the page, in absolute form (anchors excluded). +Grab a list of all links on the page, in absolute form (anchors excluded): + +.. code-block:: pycon + >>> r.html.absolute_links {'http://feedproxy.google.com/~r/PythonInsider/~3/zVC80sq9s00/python-364-is-now-available.html', 'https://www.python.org/downloads/mac-osx/', 'http://flask.pocoo.org/', 'https://www.python.org//docs.python.org/3/tutorial/', 'http://www.djangoproject.com/', 'https://wiki.python.org/moin/BeginnersGuide', 'https://www.python.org//docs.python.org/3/tutorial/controlflow.html#defining-functions', 'https://www.python.org/about/success/', 'http://twitter.com/ThePSF', 'https://www.python.org/events/python-user-group/634/', ..., 'https://wiki.python.org/moin/PythonBooks'} - # Select an element with a jQuery selector. +Select an element with a jQuery selector. + +.. code-block:: pycon + >>> about = r.html.find('#about')[0] - # Grab an element's text contents. +Grab an element's text contents: + +.. code-block:: pycon + >>> print(about.text) About Applications @@ -46,15 +59,23 @@ Usage Help Python Brochure - # Introspect an Element's attributes. +Introspect an Element's attributes: + +.. code-block:: pycon + >>> about.attrs {'id': 'about', 'class': 'tier-1 element-1 ', 'aria-haspopup': 'true'} - # Select Elements within Elements. +Select Elements within Elements: + +.. code-block:: pycon + >>> about.find('a') [, , , , , ] - # Render an Element as Markdown. +Render an Element as Markdown: + +.. code-block:: pycon >>> print(about.markdown) * [About](/about/) @@ -65,6 +86,10 @@ Usage * [Help](/about/help/) * [Python Brochure](http://brochure.getpython.info/) + Search for text on the page: + + .. code-block:: pycon + >>> r.html.search('Python is a {} language')[0] programming From 25fad4c6f182246be49800029f61be4f0bfde3fd Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 25 Feb 2018 08:23:01 -0500 Subject: [PATCH 3/4] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 81d6cb4..a2c36c1 100644 --- a/README.rst +++ b/README.rst @@ -22,7 +22,7 @@ Usage .. code-block:: pycon -Make a GET request to python.org: +Make a GET request to 'python.org', using Requests: >>> from requests_html import session >>> r = session.get('https://python.org/') From f43f3241f0c63cd50bb4286edffcc1f8ee5ae7bd Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 25 Feb 2018 08:23:40 -0500 Subject: [PATCH 4/4] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a2c36c1..629ea7b 100644 --- a/README.rst +++ b/README.rst @@ -27,7 +27,7 @@ Make a GET request to 'python.org', using Requests: >>> from requests_html import session >>> r = session.get('https://python.org/') -Grab a list of all links on the page (anchors excluded): +Grab a list of all links on the page, as–is (anchors excluded): .. code-block:: pycon