Last active
January 5, 2019 06:48
-
-
Save juque/7f869842fc95bf4f7f714587bd915dd6 to your computer and use it in GitHub Desktop.
A very simple example of web scraping using python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| import requests | |
| from bs4 import BeautifulSoup | |
| url = "https://www.bebesymas.com/alimentacion-para-bebes-y-ninos/17-alimentos-que-atragantamientos-provocan-ninos-como-ofrecerlos-para-evitarlo" | |
| response = requests.get(url).text | |
| soup = BeautifulSoup(response,'html.parser') | |
| target = soup.find('div',class_='article-content-inner') | |
| print(soup.title.text,end="\n\n") | |
| for index,sub_header in enumerate( target.find_all('h2'),start=1 ): | |
| print(("%3d. %s") % ( index,sub_header.text )) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Los 17 alimentos que más atragantamientos provocan en niños y cómo ofrecerlos para evitarlo | |
| 1. Palomitas de maíz | |
| 2. Frutos secos enteros | |
| 3. Jamón | |
| 4. Caramelos y dulces duros | |
| 5. Gominolas | |
| 6. Malvaviscos o nubes | |
| 7. Chicles | |
| 8. Uvas | |
| 9. Cerezas | |
| 10. Aceitunas | |
| 11. Salchichas | |
| 12. Zanahoria cruda en trozos | |
| 13. Manzana cruda en trozos | |
| 14. Pan | |
| 15. Galletas | |
| 16. Pescado | |
| 17. Carne | |
| 18. Y por último... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment