python:webscraping
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| python:webscraping [2024/02/05 18:50] – [Encontrar elementos] alberto | python:webscraping [2024/02/05 19:00] (actual) – [Encontrar elementos] alberto | ||
|---|---|---|---|
| Línea 126: | Línea 126: | ||
| Suponemos el siguiente código HTML | Suponemos el siguiente código HTML | ||
| - | < | + | < |
| <!-- This is the example.html example file. --> | <!-- This is the example.html example file. --> | ||
| < | < | ||
| Línea 154: | Línea 154: | ||
| 'Al Sweigart' | 'Al Sweigart' | ||
| >>> | >>> | ||
| + | {' | ||
| + | >>> | ||
| + | >>> | ||
| + | '< | ||
| + | inventwithpython.com"> | ||
| + | >>> | ||
| + | ' | ||
| + | >>> | ||
| + | '<p class=" | ||
| + | >>> | ||
| + | 'Learn Python the easy way!' | ||
| + | >>> | ||
| + | '< | ||
| + | >>> | ||
| + | 'By Al Sweigart' | ||
| + | </ | ||
| + | |||
| + | ==== Obtener datos de atributos de elementos ==== | ||
| + | Para obtener fácilmente los valores de los atributos de un elemento (objeto tipo tag), podemos usar el método **get()**. Se le pasa el string del nombre de un atributo, y devuelve su valor. Vemos un ejemplo en la consola de Python: | ||
| + | <code python> | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | >>> | ||
| + | '< | ||
| + | >>> | ||
| + | ' | ||
| + | >>> | ||
| + | True | ||
| + | >>> | ||
| {' | {' | ||
| </ | </ | ||
| ===== Módulo selenium ===== | ===== Módulo selenium ===== | ||
python/webscraping.1707155457.txt.gz · Última modificación: por alberto
