selenium como herramienta de web scraping
Post on 30-Aug-2014
3.902 Views
Preview:
DESCRIPTION
TRANSCRIPT
Selenium como herramienta de Web Scraping
@dani_latorre - 26/08/2013 - Zaragoza Python Days
Web Scraping
• “... es una técnica utilizada mediante programas de software para extraer información de sitios web.”
• Ingeniería inversa
• Controvertido
Selenium
• “Selenium is a suite of tools to automate web browsers across many platforms.”
• Testing de aceptación web
• Automatización de acciones de usuario
• Web scraping
Bindings• Python
• Java
• C#
• Ruby
• Javascript - Node
• PHP, Perl (mantenidos por terceros)
Otras librerías
• urllib
• Mechanize
• BeautifulSoup/lxml
• Scrapy (crawling)
Viene bien
• XPath
• Selectores CSS
• Expresiones Regulares
• Mucha paciencia
¿Por qué selenium?
Caso ShuttleCloud
• Migración entre proveedores de email
• Necesidad de escalabilidad
• Homogeneizar scrapers
• Herramienta madura
Infraestructura (EC2)• 1 Selenium Hub
• 3 Selenium Grid (15 firefox)
• 1 BrowserMob Proxy
• 3 BigCouch
• 1 Rabbit MQ
• 1 Scrapers
Selenium with Python
find_element_by...• _id / _name
• _tag_name
• _link_text / _partial_link_text
• _class_name
• _css_selector
• _xpath
Navegación• get("http://dlabs.co/")
• anchor_element.click()
• switch_to_window("name")
• switch_to_frame("name")
• add_cookie({"key": "value"})
• get_cookies()
Interacción
• input.send_keys("some text")
• input.clear()
• option.click()
• submit.click()
• execute_script(“alert(‘foo’)”)
https://gist.github.com/danilat/6341150
Gracias
top related