I am trying to find if a given line, say βHelloβ, exists on this page. So far I have the following:
agent = Mechanize.new page = agent.get('http://www.google.de/')
and what should I do now? I saw the search method, but it only accepts XPath / CSS expressions. I could try using xpath to search, but is there a better way?
You can simply do a general text search:
page.body.include?('Hello')
However, when searching in a specific html node, I recommend using the css selector as follows:
page.parser.css('#my_container_element').text.include? 'Hello'
Source: https://habr.com/ru/post/1491613/More articles:Jquery filter: get only the first match? - jqueryStore a list of images in a django model - pythoncss circles using border radius should change color of crossed section of circles - cssDisable drag and drop option in Flexigrid jQuery? - jqueryIs there a cleaning function that puts age in a group bucket? - phpWhy does my email sending method for Android not work - javaAs for iOS, what is the difference between the Concurrency programming guide and the thread programming guide? - multithreadingMKMapView with multiple overlay memory issues - iosAngularjs Routing behaves strangely when using the tabset directive from ui-bootstrap - javascriptGoogle maps drags a rectangle to select markers - javascriptAll Articles