Web Scraping With Ruby
Introduction to web scraping with Ruby. How to handle http connections, parse html files for data, best practices, tips and an example project.
To select elements by element ID using XPath we can match the @id
attribute using the =
operator or the contains()
function.
For example, to select <a id="home"></a>
element we could use //a[@id="home"]
or //a[contains(@id, "home")]
selectors. See these interactive examples:
For dynamic IDs we can use contains()
to match elements by partial ID: