Scraping, HTML

Los componentes de una página web, archivo html, css y javascript (en su forma más sencilla)

import re
import requests
from bs4 import BeautifulSoup
link = "http://rafneta.github.io/Notas/NotasSyS/index.html"
pagina = requests.get(link)
#pagina.content
pagina.content[0:500]
b'<!DOCTYPE html>\n<html lang="en" class="no-js">\n\t<head>\n\t\t<meta charset="UTF-8" />\n\t\t<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> \n\t\t<meta name="viewport" content="width=device-width, initial-scale=1.0"> \n\t\t<title>Se\xc3\xb1ales y sistemas: Una perspectiva</title>\n        <!--<link rel="stylesheet" href="css/letras1.css">-->\n\t\t<meta name="description" content="Libro en Linea" />\n\t\t<meta name="keywords" content="Se\xc3\xb1ales, sistemas, apuntes, libro" />\n\t\t<meta name="author" content="Rafa'
pes1=re.findall(r"(<p>[\s+|\n+|\w+]?.+</p>)",str(pagina.content,'utf-8'))
print(len(pes1))
pes1[0:3]
294
['<p><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Licencia Creative Commons" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" width="15%" height="15%" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Señales y sistemas: una perspectiva</span> por <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.mateyasi.org/portada.html" property="cc:attributionName" rel="cc:attributionURL">Rafael Martínez-Martínez</a> se distribuye bajo una <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Licencia Creative Commons Atribución-NoComercial-CompartirIgual 4.0 Internacional</a>.</p>',
 '<p>Los autores han hecho su mejor esfuerzo en la preparación de este material. Se distribuye gratuitamente con la esperanza de que sea útil, pero sin ninguna garantía expresa o implícita respecto a la exactitud o completitud del contenido.</p>',
 '<p>Este prefacio (así como todo el documento electrónico) es variante respecto al tiempo, lo que consultes dependerá de la fecha y hora en que lo hagas. Creo (no tengo una referencia que confirme lo que escribiré) que los libros usuales han sido parte de la educación por tradición, es claro que hace décadas (por no decir siglos) una de las formas de almacenar los conocimientos era escribiendo libros y claro que la experiencia de interactuar con un libro es inigualable. En la actualidad tenemos herramientas tecnológicas (tantas que no sabemos que elegir) para almacenar información, transmitir y enseña, simular situaciones, etc. Por tal motivo este ""libro"" (le llamaremos documento electrónico) es un poco diferente a lo usual. Se presenta de manera escrita la teoría, pero muchas de las explicaciones son mediante video, lo cual acota a que la consulta sea mediante un dispositivo digital (por tal motivo lo definimos como un documento electrónico).</p>']
soup = BeautifulSoup(pagina.content, 'html.parser')
pes=soup.findAll("p")
print(len(pes))
pes[0:3]
333
[<p><br/>La licencia es lo siguiente:
 
 Permite a otros copiar, distribuir, exhibir y ejecutar públicamente el trabajo, así como hacer y distribuir trabajos derivados con fines no comerciales pero reconociendo la autoría y sólo bajo la misma licencia o una compatible.</p>,
 <p><a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" rel="license"><img alt="Licencia Creative Commons" height="15%" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" style="border-width:0" width="15%"/></a><br><span property="dct:title" xmlns:dct="http://purl.org/dc/terms/">Señales y sistemas: una perspectiva</span> por <a href="http://www.mateyasi.org/portada.html" property="cc:attributionName" rel="cc:attributionURL" xmlns:cc="http://creativecommons.org/ns#">Rafael Martínez-Martínez</a> se distribuye bajo una <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" rel="license">Licencia Creative Commons Atribución-NoComercial-CompartirIgual 4.0 Internacional</a>.</br></p>,
 <p>Los autores han hecho su mejor esfuerzo en la preparación de este material. Se distribuye gratuitamente con la esperanza de que sea útil, pero sin ninguna garantía expresa o implícita respecto a la exactitud o completitud del contenido.</p>]
a=soup.findAll("p", class_ = "justo")
a
[<p class="justo">
                     Si \( \mathbb{R}e(a)&gt;0\) la evalución
                     \({ \left. t{ e }^{ -(a+j\omega )t } \right|  }_{ 0 }^{ \infty  }=0\),
                     se tiene que:</p>,
 <p class="justo">
                       de acuerdo a la definición de valor absoluto
                       </p>,
 <p class="justo">
                     Si \( \mathbb{R}e(a)&gt;0\) las evaluciones son \(1\) y \(-1\)
             repectivamente, al operar el signo en el denominador de la 
             primera expresión se tiene que:</p>]
help(a[1])
Help on Tag in module bs4.element object:

class Tag(PageElement)
 |  Tag(parser=None, builder=None, name=None, namespace=None, prefix=None, attrs=None, parent=None, previous=None, is_xml=None, sourceline=None, sourcepos=None, can_be_empty_element=None, cdata_list_attributes=None, preserve_whitespace_tags=None)
 |  
 |  Represents an HTML or XML tag that is part of a parse tree, along
 |  with its attributes and contents.
 |  
 |  When Beautiful Soup parses the markup <b>penguin</b>, it will
 |  create a Tag object representing the <b> tag.
 |  
 |  Method resolution order:
 |      Tag
 |      PageElement
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __bool__(self)
 |      A tag is non-None even if it has no contents.
 |  
 |  __call__(self, *args, **kwargs)
 |      Calling a Tag like a function is the same as calling its
 |      find_all() method. Eg. tag('a') returns a list of all the A tags
 |      found within this tag.
 |  
 |  __contains__(self, x)
 |  
 |  __copy__(self)
 |      A copy of a Tag is a new Tag, unconnected to the parse tree.
 |      Its contents are a copy of the old Tag's contents.
 |  
 |  __delitem__(self, key)
 |      Deleting tag[key] deletes all 'key' attributes for the tag.
 |  
 |  __eq__(self, other)
 |      Returns true iff this Tag has the same name, the same attributes,
 |      and the same contents (recursively) as `other`.
 |  
 |  __getattr__(self, tag)
 |      Calling tag.subtag is the same as calling tag.find(name="subtag")
 |  
 |  __getitem__(self, key)
 |      tag[key] returns the value of the 'key' attribute for the Tag,
 |      and throws an exception if it's not there.
 |  
 |  __hash__(self)
 |      Return hash(self).
 |  
 |  __init__(self, parser=None, builder=None, name=None, namespace=None, prefix=None, attrs=None, parent=None, previous=None, is_xml=None, sourceline=None, sourcepos=None, can_be_empty_element=None, cdata_list_attributes=None, preserve_whitespace_tags=None)
 |      Basic constructor.
 |      
 |      :param parser: A BeautifulSoup object.
 |      :param builder: A TreeBuilder.
 |      :param name: The name of the tag.
 |      :param namespace: The URI of this Tag's XML namespace, if any.
 |      :param prefix: The prefix for this Tag's XML namespace, if any.
 |      :param attrs: A dictionary of this Tag's attribute values.
 |      :param parent: The PageElement to use as this Tag's parent.
 |      :param previous: The PageElement that was parsed immediately before
 |          this tag.
 |      :param is_xml: If True, this is an XML tag. Otherwise, this is an
 |          HTML tag.
 |      :param sourceline: The line number where this tag was found in its
 |          source document.
 |      :param sourcepos: The character position within `sourceline` where this
 |          tag was found.
 |      :param can_be_empty_element: If True, this tag should be
 |          represented as <tag/>. If False, this tag should be represented
 |          as <tag></tag>.
 |      :param cdata_list_attributes: A list of attributes whose values should
 |          be treated as CDATA if they ever show up on this tag.
 |      :param preserve_whitespace_tags: A list of tag names whose contents
 |          should have their whitespace preserved.
 |  
 |  __iter__(self)
 |      Iterating over a Tag iterates over its contents.
 |  
 |  __len__(self)
 |      The length of a Tag is the length of its list of contents.
 |  
 |  __ne__(self, other)
 |      Returns true iff this Tag is not identical to `other`,
 |      as defined in __eq__.
 |  
 |  __repr__ = __unicode__(self)
 |  
 |  __setitem__(self, key, value)
 |      Setting tag[key] sets the value of the 'key' attribute for the
 |      tag.
 |  
 |  __str__ = __unicode__(self)
 |  
 |  __unicode__(self)
 |      Renders this PageElement as a Unicode string.
 |  
 |  childGenerator(self)
 |      Deprecated generator.
 |  
 |  clear(self, decompose=False)
 |      Wipe out all children of this PageElement by calling extract()
 |         on them.
 |      
 |      :param decompose: If this is True, decompose() (a more
 |          destructive method) will be called instead of extract().
 |  
 |  decode(self, indent_level=None, eventual_encoding='utf-8', formatter='minimal')
 |      Render a Unicode representation of this PageElement and its
 |      contents.
 |      
 |      :param indent_level: Each line of the rendering will be
 |           indented this many spaces. Used internally in
 |           recursive calls while pretty-printing.
 |      :param eventual_encoding: The tag is destined to be
 |          encoded into this encoding. This method is _not_
 |          responsible for performing that encoding. This information
 |          is passed in so that it can be substituted in if the
 |          document contains a <META> tag that mentions the document's
 |          encoding.
 |      :param formatter: A Formatter object, or a string naming one of
 |          the standard formatters.
 |  
 |  decode_contents(self, indent_level=None, eventual_encoding='utf-8', formatter='minimal')
 |      Renders the contents of this tag as a Unicode string.
 |      
 |      :param indent_level: Each line of the rendering will be
 |         indented this many spaces. Used internally in
 |         recursive calls while pretty-printing.
 |      
 |      :param eventual_encoding: The tag is destined to be
 |         encoded into this encoding. decode_contents() is _not_
 |         responsible for performing that encoding. This information
 |         is passed in so that it can be substituted in if the
 |         document contains a <META> tag that mentions the document's
 |         encoding.
 |      
 |      :param formatter: A Formatter object, or a string naming one of
 |          the standard Formatters.
 |  
 |  decompose(self)
 |      Recursively destroys this PageElement and its children.
 |      
 |      This element will be removed from the tree and wiped out; so
 |      will everything beneath it.
 |      
 |      The behavior of a decomposed PageElement is undefined and you
 |      should never use one for anything, but if you need to _check_
 |      whether an element has been decomposed, you can use the
 |      `decomposed` property.
 |  
 |  encode(self, encoding='utf-8', indent_level=None, formatter='minimal', errors='xmlcharrefreplace')
 |      Render a bytestring representation of this PageElement and its
 |      contents.
 |      
 |      :param encoding: The destination encoding.
 |      :param indent_level: Each line of the rendering will be
 |          indented this many spaces. Used internally in
 |          recursive calls while pretty-printing.
 |      :param formatter: A Formatter object, or a string naming one of
 |          the standard formatters.
 |      :param errors: An error handling strategy such as
 |          'xmlcharrefreplace'. This value is passed along into
 |          encode() and its value should be one of the constants
 |          defined by Python.
 |      :return: A bytestring.
 |  
 |  encode_contents(self, indent_level=None, encoding='utf-8', formatter='minimal')
 |      Renders the contents of this PageElement as a bytestring.
 |      
 |      :param indent_level: Each line of the rendering will be
 |         indented this many spaces. Used internally in
 |         recursive calls while pretty-printing.
 |      
 |      :param eventual_encoding: The bytestring will be in this encoding.
 |      
 |      :param formatter: A Formatter object, or a string naming one of
 |          the standard Formatters.
 |      
 |      :return: A bytestring.
 |  
 |  find(self, name=None, attrs={}, recursive=True, text=None, **kwargs)
 |      Look in the children of this PageElement and find the first
 |      PageElement that matches the given criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param recursive: If this is True, find() will perform a
 |          recursive search of this PageElement's children. Otherwise,
 |          only the direct children will be considered.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  findAll = find_all(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs)
 |  
 |  findChild = find(self, name=None, attrs={}, recursive=True, text=None, **kwargs)
 |  
 |  findChildren = find_all(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs)
 |  
 |  find_all(self, name=None, attrs={}, recursive=True, text=None, limit=None, **kwargs)
 |      Look in the children of this PageElement and find all
 |      PageElements that match the given criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param recursive: If this is True, find_all() will perform a
 |          recursive search of this PageElement's children. Otherwise,
 |          only the direct children will be considered.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A ResultSet of PageElements.
 |      :rtype: bs4.element.ResultSet
 |  
 |  get(self, key, default=None)
 |      Returns the value of the 'key' attribute for the tag, or
 |      the value given for 'default' if it doesn't have that
 |      attribute.
 |  
 |  getText = get_text(self, separator='', strip=False, types=(<class 'bs4.element.NavigableString'>, <class 'bs4.element.CData'>))
 |  
 |  get_attribute_list(self, key, default=None)
 |      The same as get(), but always returns a list.
 |      
 |      :param key: The attribute to look for.
 |      :param default: Use this value if the attribute is not present
 |          on this PageElement.
 |      :return: A list of values, probably containing only a single
 |          value.
 |  
 |  get_text(self, separator='', strip=False, types=(<class 'bs4.element.NavigableString'>, <class 'bs4.element.CData'>))
 |      Get all child strings, concatenated using the given separator.
 |      
 |      :param separator: Strings will be concatenated using this separator.
 |      
 |      :param strip: If True, strings will be stripped before being
 |          concatenated.
 |      
 |      :types: A tuple of NavigableString subclasses. Any strings of
 |          a subclass not found in this list will be ignored. By
 |          default, this means only NavigableString and CData objects
 |          will be considered. So no comments, processing instructions,
 |          stylesheets, etc.
 |      
 |      :return: A string.
 |  
 |  has_attr(self, key)
 |      Does this PageElement have an attribute with the given name?
 |  
 |  has_key(self, key)
 |      Deprecated method. This was kind of misleading because has_key()
 |      (attributes) was different from __in__ (contents).
 |      
 |      has_key() is gone in Python 3, anyway.
 |  
 |  index(self, element)
 |      Find the index of a child by identity, not value.
 |      
 |      Avoids issues with tag.contents.index(element) getting the
 |      index of equal elements.
 |      
 |      :param element: Look for this PageElement in `self.contents`.
 |  
 |  prettify(self, encoding=None, formatter='minimal')
 |      Pretty-print this PageElement as a string.
 |      
 |      :param encoding: The eventual encoding of the string. If this is None,
 |          a Unicode string will be returned.
 |      :param formatter: A Formatter object, or a string naming one of
 |          the standard formatters.
 |      :return: A Unicode string (if encoding==None) or a bytestring 
 |          (otherwise).
 |  
 |  recursiveChildGenerator(self)
 |      Deprecated generator.
 |  
 |  renderContents(self, encoding='utf-8', prettyPrint=False, indentLevel=0)
 |      Deprecated method for BS3 compatibility.
 |  
 |  select(self, selector, namespaces=None, limit=None, **kwargs)
 |      Perform a CSS selection operation on the current element.
 |      
 |      This uses the SoupSieve library.
 |      
 |      :param selector: A string containing a CSS selector.
 |      
 |      :param namespaces: A dictionary mapping namespace prefixes
 |         used in the CSS selector to namespace URIs. By default,
 |         Beautiful Soup will use the prefixes it encountered while
 |         parsing the document.
 |      
 |      :param limit: After finding this number of results, stop looking.
 |      
 |      :param kwargs: Keyword arguments to be passed into SoupSieve's 
 |         soupsieve.select() method.
 |      
 |      :return: A ResultSet of Tags.
 |      :rtype: bs4.element.ResultSet
 |  
 |  select_one(self, selector, namespaces=None, **kwargs)
 |      Perform a CSS selection operation on the current element.
 |      
 |      :param selector: A CSS selector.
 |      
 |      :param namespaces: A dictionary mapping namespace prefixes
 |         used in the CSS selector to namespace URIs. By default,
 |         Beautiful Soup will use the prefixes it encountered while
 |         parsing the document.
 |      
 |      :param kwargs: Keyword arguments to be passed into SoupSieve's 
 |         soupsieve.select() method.
 |      
 |      :return: A Tag.
 |      :rtype: bs4.element.Tag
 |  
 |  smooth(self)
 |      Smooth out this element's children by consolidating consecutive
 |      strings.
 |      
 |      This makes pretty-printed output look more natural following a
 |      lot of operations that modified the tree.
 |  
 |  ----------------------------------------------------------------------
 |  Readonly properties defined here:
 |  
 |  children
 |      Iterate over all direct children of this PageElement.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  descendants
 |      Iterate over all children of this PageElement in a
 |      breadth-first sequence.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  isSelfClosing
 |      Is this tag an empty-element tag? (aka a self-closing tag)
 |      
 |      A tag that has contents is never an empty-element tag.
 |      
 |      A tag that has no contents may or may not be an empty-element
 |      tag. It depends on the builder used to create the tag. If the
 |      builder has a designated list of empty-element tags, then only
 |      a tag whose name shows up in that list is considered an
 |      empty-element tag.
 |      
 |      If the builder has no designated list of empty-element tags,
 |      then any tag with no contents is an empty-element tag.
 |  
 |  is_empty_element
 |      Is this tag an empty-element tag? (aka a self-closing tag)
 |      
 |      A tag that has contents is never an empty-element tag.
 |      
 |      A tag that has no contents may or may not be an empty-element
 |      tag. It depends on the builder used to create the tag. If the
 |      builder has a designated list of empty-element tags, then only
 |      a tag whose name shows up in that list is considered an
 |      empty-element tag.
 |      
 |      If the builder has no designated list of empty-element tags,
 |      then any tag with no contents is an empty-element tag.
 |  
 |  strings
 |      Yield all strings of certain classes, possibly stripping them.
 |      
 |      :param strip: If True, all strings will be stripped before being
 |          yielded.
 |      
 |      :types: A tuple of NavigableString subclasses. Any strings of
 |          a subclass not found in this list will be ignored. By
 |          default, this means only NavigableString and CData objects
 |          will be considered. So no comments, processing instructions,
 |          etc.
 |      
 |      :yield: A sequence of strings.
 |  
 |  stripped_strings
 |      Yield all strings in the document, stripping them first.
 |      
 |      :yield: A sequence of stripped strings.
 |  
 |  text
 |      Get all child strings, concatenated using the given separator.
 |      
 |      :param separator: Strings will be concatenated using this separator.
 |      
 |      :param strip: If True, strings will be stripped before being
 |          concatenated.
 |      
 |      :types: A tuple of NavigableString subclasses. Any strings of
 |          a subclass not found in this list will be ignored. By
 |          default, this means only NavigableString and CData objects
 |          will be considered. So no comments, processing instructions,
 |          stylesheets, etc.
 |      
 |      :return: A string.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  parserClass
 |  
 |  string
 |      Convenience property to get the single string within this
 |      PageElement.
 |      
 |      TODO It might make sense to have NavigableString.string return
 |      itself.
 |      
 |      :return: If this element has a single string child, return
 |       value is that string. If this element has one child tag,
 |       return value is the 'string' attribute of the child tag,
 |       recursively. If this element is itself a string, has no
 |       children, or has more than one child, return value is None.
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from PageElement:
 |  
 |  append(self, tag)
 |      Appends the given PageElement to the contents of this one.
 |      
 |      :param tag: A PageElement.
 |  
 |  extend(self, tags)
 |      Appends the given PageElements to this one's contents.
 |      
 |      :param tags: A list of PageElements.
 |  
 |  extract(self, _self_index=None)
 |      Destructively rips this element out of the tree.
 |      
 |      :param _self_index: The location of this element in its parent's
 |         .contents, if known. Passing this in allows for a performance
 |         optimization.
 |      
 |      :return: `self`, no longer part of the tree.
 |  
 |  fetchNextSiblings = find_next_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  fetchParents = find_parents(self, name=None, attrs={}, limit=None, **kwargs)
 |  
 |  fetchPrevious = find_all_previous(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  fetchPreviousSiblings = find_previous_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  findAllNext = find_all_next(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  findAllPrevious = find_all_previous(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  findNext = find_next(self, name=None, attrs={}, text=None, **kwargs)
 |  
 |  findNextSibling = find_next_sibling(self, name=None, attrs={}, text=None, **kwargs)
 |  
 |  findNextSiblings = find_next_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  findParent = find_parent(self, name=None, attrs={}, **kwargs)
 |  
 |  findParents = find_parents(self, name=None, attrs={}, limit=None, **kwargs)
 |  
 |  findPrevious = find_previous(self, name=None, attrs={}, text=None, **kwargs)
 |  
 |  findPreviousSibling = find_previous_sibling(self, name=None, attrs={}, text=None, **kwargs)
 |  
 |  findPreviousSiblings = find_previous_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |  
 |  find_all_next(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |      Find all PageElements that match the given criteria and appear
 |      later in the document than this PageElement.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A ResultSet containing PageElements.
 |  
 |  find_all_previous(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |      Look backwards in the document from this PageElement and find all
 |      PageElements that match the given criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A ResultSet of PageElements.
 |      :rtype: bs4.element.ResultSet
 |  
 |  find_next(self, name=None, attrs={}, text=None, **kwargs)
 |      Find the first PageElement that matches the given criteria and
 |      appears later in the document than this PageElement.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_next_sibling(self, name=None, attrs={}, text=None, **kwargs)
 |      Find the closest sibling to this PageElement that matches the
 |      given criteria and appears later in the document.
 |      
 |      All find_* methods take a common set of arguments. See the
 |      online documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_next_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |      Find all siblings of this PageElement that match the given criteria
 |      and appear later in the document.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A ResultSet of PageElements.
 |      :rtype: bs4.element.ResultSet
 |  
 |  find_parent(self, name=None, attrs={}, **kwargs)
 |      Find the closest parent of this PageElement that matches the given
 |      criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :kwargs: A dictionary of filters on attribute values.
 |      
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_parents(self, name=None, attrs={}, limit=None, **kwargs)
 |      Find all parents of this PageElement that match the given criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_previous(self, name=None, attrs={}, text=None, **kwargs)
 |      Look backwards in the document from this PageElement and find the
 |      first PageElement that matches the given criteria.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_previous_sibling(self, name=None, attrs={}, text=None, **kwargs)
 |      Returns the closest sibling to this PageElement that matches the
 |      given criteria and appears earlier in the document.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  find_previous_siblings(self, name=None, attrs={}, text=None, limit=None, **kwargs)
 |      Returns all siblings to this PageElement that match the
 |      given criteria and appear earlier in the document.
 |      
 |      All find_* methods take a common set of arguments. See the online
 |      documentation for detailed explanations.
 |      
 |      :param name: A filter on tag name.
 |      :param attrs: A dictionary of filters on attribute values.
 |      :param text: A filter for a NavigableString with specific text.
 |      :param limit: Stop looking after finding this many results.
 |      :kwargs: A dictionary of filters on attribute values.
 |      :return: A ResultSet of PageElements.
 |      :rtype: bs4.element.ResultSet
 |  
 |  format_string(self, s, formatter)
 |      Format the given string using the given formatter.
 |      
 |      :param s: A string.
 |      :param formatter: A Formatter object, or a string naming one of the standard formatters.
 |  
 |  formatter_for_name(self, formatter)
 |      Look up or create a Formatter for the given identifier,
 |      if necessary.
 |      
 |      :param formatter: Can be a Formatter object (used as-is), a
 |          function (used as the entity substitution hook for an
 |          XMLFormatter or HTMLFormatter), or a string (used to look
 |          up an XMLFormatter or HTMLFormatter in the appropriate
 |          registry.
 |  
 |  insert(self, position, new_child)
 |      Insert a new PageElement in the list of this PageElement's children.
 |      
 |      This works the same way as `list.insert`.
 |      
 |      :param position: The numeric position that should be occupied
 |         in `self.children` by the new PageElement. 
 |      :param new_child: A PageElement.
 |  
 |  insert_after(self, *args)
 |      Makes the given element(s) the immediate successor of this one.
 |      
 |      The elements will have the same parent, and the given elements
 |      will be immediately after this one.
 |      
 |      :param args: One or more PageElements.
 |  
 |  insert_before(self, *args)
 |      Makes the given element(s) the immediate predecessor of this one.
 |      
 |      All the elements will have the same parent, and the given elements
 |      will be immediately before this one.
 |      
 |      :param args: One or more PageElements.
 |  
 |  nextGenerator(self)
 |      # Old non-property versions of the generators, for backwards
 |      # compatibility with BS3.
 |  
 |  nextSiblingGenerator(self)
 |  
 |  parentGenerator(self)
 |  
 |  previousGenerator(self)
 |  
 |  previousSiblingGenerator(self)
 |  
 |  replaceWith = replace_with(self, replace_with)
 |  
 |  replaceWithChildren = unwrap(self)
 |  
 |  replace_with(self, replace_with)
 |      Replace this PageElement with another one, keeping the rest of the
 |      tree the same.
 |      
 |      :param replace_with: A PageElement.
 |      :return: `self`, no longer part of the tree.
 |  
 |  replace_with_children = unwrap(self)
 |  
 |  setup(self, parent=None, previous_element=None, next_element=None, previous_sibling=None, next_sibling=None)
 |      Sets up the initial relations between this element and
 |      other elements.
 |      
 |      :param parent: The parent of this element.
 |      
 |      :param previous_element: The element parsed immediately before
 |          this one.
 |      
 |      :param next_element: The element parsed immediately before
 |          this one.
 |      
 |      :param previous_sibling: The most recently encountered element
 |          on the same level of the parse tree as this one.
 |      
 |      :param previous_sibling: The next element to be encountered
 |          on the same level of the parse tree as this one.
 |  
 |  unwrap(self)
 |      Replace this PageElement with its contents.
 |      
 |      :return: `self`, no longer part of the tree.
 |  
 |  wrap(self, wrap_inside)
 |      Wrap this PageElement inside another one.
 |      
 |      :param wrap_inside: A PageElement.
 |      :return: `wrap_inside`, occupying the position in the tree that used
 |         to be occupied by `self`, and with `self` inside it.
 |  
 |  ----------------------------------------------------------------------
 |  Readonly properties inherited from PageElement:
 |  
 |  decomposed
 |      Check whether a PageElement has been decomposed.
 |      
 |      :rtype: bool
 |  
 |  next
 |      The PageElement, if any, that was parsed just after this one.
 |      
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  next_elements
 |      All PageElements that were parsed after this one.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  next_siblings
 |      All PageElements that are siblings of this one but were parsed
 |      later.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  parents
 |      All PageElements that are parents of this PageElement.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  previous
 |      The PageElement, if any, that was parsed just before this one.
 |      
 |      :return: A PageElement.
 |      :rtype: bs4.element.Tag | bs4.element.NavigableString
 |  
 |  previous_elements
 |      All PageElements that were parsed before this one.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  previous_siblings
 |      All PageElements that are siblings of this one but were parsed
 |      earlier.
 |      
 |      :yield: A sequence of PageElements.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from PageElement:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  nextSibling
 |  
 |  previousSibling
a[1].text
'\n                      de acuerdo a la definición de valor absoluto\n                      '
texto=re.findall(r"[^\n].+",a[1].text)
texto=re.findall(r"\w+\s?",texto[0])
" ".join(texto)
'de  acuerdo  a  la  definición  de  valor  absoluto'
link = "https://www.amazon.com.mx/"
pagina = requests.get(link)
#pagina.content
pagina.content
b'<!DOCTYPE html>\n<!--[if lt IE 7]> <html lang="es-mx" class="a-no-js a-lt-ie9 a-lt-ie8 a-lt-ie7"> <![endif]-->\n<!--[if IE 7]>    <html lang="es-mx" class="a-no-js a-lt-ie9 a-lt-ie8"> <![endif]-->\n<!--[if IE 8]>    <html lang="es-mx" class="a-no-js a-lt-ie9"> <![endif]-->\n<!--[if gt IE 8]><!-->\n<html class="a-no-js" lang="es-mx"><!--<![endif]--><head>\n    <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n    <meta charset="utf-8">\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\n    <title dir="ltr">Amazon.com.mx</title>\n    <meta name="viewport" content="width=device-width">\n    <link rel="stylesheet" href="https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AmazonUI-3c913031596ca78a3768f4e934b1cc02ce238101.secure.min._V1_.css">\n    <script>\n        \n        if (true === true) {\n            var ue_t0 = (+ new Date()),\n                ue_csm = window,\n                ue = { t0: ue_t0, d: function() { return (+new Date() - ue_t0); } },\n                ue_furl = "fls-na.amazon.com",\n                ue_mid = "A1AM78C64UM0Y8",\n                ue_sid = (document.cookie.match(/session-id=([0-9-]+)/) || [])[1],\n                ue_sn = "opfcaptcha.amazon.com.mx",\n                ue_id = \'KXVYY7D7T1G6YC1RSHY0\';\n        }\n    </script>\n</head>\n<body>\n\n<!--\nPara comentar el acceso automatizado a los datos de Amazon, ponte en contacto con api-services-support@amazon.com.\nPara obtener informaci\xc3\xb3n sobre la migraci\xc3\xb3n a nuestras API, consulta nuestras API de Marketplace en https://developer.amazonservices.com/ref=rm_c_sv o nuestra Publicidad de Productos API en https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html/ref=rm_c_ac para ver los casos de uso publicitario.\n\nTo discuss automated access to Amazon data please contact api-services-support@amazon.com.\nFor information about migrating to our APIs refer to our Marketplace APIs at https://developer.amazonservices.com/ref=rm_c_sv, or our Product Advertising API at https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html/ref=rm_c_ac for advertising use cases.\n-->\n\n<!--\nCorreios.DoNotSend\n-->\n\n<div class="a-container a-padding-double-large" style="min-width:350px;padding:44px 0 !important">\n\n    <div class="a-row a-spacing-double-large" style="width: 350px; margin: 0 auto">\n\n        <div class="a-row a-spacing-medium a-text-center"><i class="a-icon a-logo"></i></div>\n\n        <div class="a-box a-alert a-alert-info a-spacing-base">\n            <div class="a-box-inner">\n                <i class="a-icon a-icon-alert"></i>\n                <h4>Ingresar los caracteres que aparecen a continuaci\xc3\xb3n</h4>\n                <p class="a-last">Sentimos las molestias. Necesitamos asegurarnos de que no eres un robot. Para obtener los mejores resultados, aseg\xc3\xbarate de que tu navegador acepta las cookies.</p>\n            </div>\n        </div>\n\n        <div class="a-section">\n\n            <div class="a-box a-color-offset-background">\n                <div class="a-box-inner a-padding-extra-large">\n\n                    <form method="get" action="/errors/validateCaptcha" name="">\n                        <input type=hidden name="amzn" value="d18slFzezajSlC/aTgww+g==" /><input type=hidden name="amzn-r" value="&#047;" />\n                        <div class="a-row a-spacing-large">\n                            <div class="a-box">\n                                <div class="a-box-inner">\n                                    <h4>Ingresar los caracteres</h4>\n                                    <div class="a-row a-text-center">\n                                        <img src="https://images-na.ssl-images-amazon.com/captcha/nzwwotmg/Captcha_hkbxcrakzw.jpg">\n                                    </div>\n                                    <div class="a-row a-spacing-base">\n                                        <div class="a-row">\n                                            <div class="a-column a-span6">\n                                            </div>\n                                            <div class="a-column a-span6 a-span-last a-text-right">\n                                                <a onclick="window.location.reload()">Probar una imagen diferente</a>\n                                            </div>\n                                        </div>\n                                        <input autocomplete="off" spellcheck="false" placeholder="Ingresar los caracteres" id="captchacharacters" name="field-keywords" class="a-span12" autocapitalize="off" autocorrect="off" type="text">\n                                    </div>\n                                </div>\n                            </div>\n                        </div>\n\n                        <div class="a-section a-spacing-extra-large">\n\n                            <div class="a-row">\n                                     <span class="a-button a-button-primary a-span12">\n                                         <span class="a-button-inner">\n                                             <button type="submit" class="a-button-text">Continuar a Compras</button>\n                                         </span>\n                                     </span>\n                            </div>\n\n                        </div>\n                    </form>\n\n                </div>\n            </div>\n\n        </div>\n\n    </div>\n\n    <div class="a-divider a-divider-section"><div class="a-divider-inner"></div></div>\n\n    <div class="a-text-center a-spacing-small a-size-mini">\n        <a href="https://www.amazon.com.mx/gp/help/customer/display.html?ie=UTF8&nodeId=508088">Condiciones de Uso</a>\n        <span class="a-letter-space"></span>\n        <span class="a-letter-space"></span>\n        <span class="a-letter-space"></span>\n        <span class="a-letter-space"></span>\n        <a href="https://www.amazon.com.mx/gp/help/customer/display.html?ie=UTF8&nodeId=468496">Aviso de Privacidad</a>\n    </div>\n    <div class="a-text-center a-size-mini a-color-secondary">\n        \xc2\xa9 1996-2020, Amazon.com, Inc. o afiliados. Todos los derechos reservados.\n        <script>\n            if (true === true) {\n                document.write(\'<img src="https://fls-na.amaz\'+\'on.com/\'+\'1/oc-csi/1/OP/requestId=KXVYY7D7T1G6YC1RSHY0&js=1" />\');\n            };\n        </script>\n        <noscript>\n            <img src="https://fls-na.amazon.com/1/oc-csi/1/OP/requestId=KXVYY7D7T1G6YC1RSHY0&js=0" />\n        </noscript>\n    </div>\n</div>\n<script>\n    if (true === true) {\n        var head = document.getElementsByTagName(\'head\')[0],\n            prefix = "https://images-na.ssl-images-amazon.com/images/G/01/csminstrumentation/",\n            elem = document.createElement("script");\n        elem.src = prefix + "csm-captcha-instrumentation.min.js";\n        head.appendChild(elem);\n\n        elem = document.createElement("script");\n        elem.src = prefix + "rd-script-6d68177fa6061598e9509dc4b5bdd08d.js";\n        head.appendChild(elem);\n    }\n</script>\n</body></html>'