Note that there are some explanatory texts on larger screens.

plurals
  1. POStripping out results from a website that doesn't have differing URLs
    primarykey
    data
    text
    <p>I'm trying to automate the process of searching for alternative telephone numbers using <a href="http://www.saynoto0870.com" rel="nofollow">SayNoTo0870</a> . Every time one searches for an alternate number or name it brings up the <code>'/companysearch.php'</code> page. </p> <p>Clearly this page has no reference, and in my mind you can't just link to this page. </p> <p>What I'm hoping to do is use the code below, to automate the opening of a browser, searching of a name/number, stripping out the HTML and then providing the top 5 results. I've got the automation part down, but clearly when trying to save the webpage using Hpricot it only brings up the 'Sorry nothing can be found page' because I can't link directly to the search result page.</p> <p>Here is my code thus far: (I've removed comments to shorten it)</p> <pre><code>require 'rubygems' require 'watir' require 'hpricot' require 'open-uri' class OH870 def searchName(name) browser = Watir::Browser.new browser.goto 'http://www.saynoto0870.com/search.php' browser.text_field(:name =&gt; 'search_name').set name browser.button(:name =&gt; 'submit').click end def searchNumber(number) browser = Watir::Browser.new browser.goto 'http://www.saynoto0870.com/search.php' browser.text_field(:name =&gt; 'number').set number browser.button(:name =&gt; 'submit').click end def loadNew(website) doc = Hpricot(open(website)) puts(doc) end def strip_tags stripped = website.gsub( %r{&lt;/?[^&gt;]+?&gt;}, '' ) puts stripped end end # class class Main &lt; OH870 puts "What is the name of the place you want?" website = 'http://www.saynoto0870.com/companysearch.php' question = gets.chomp whichNumber = OH870.new whichNumber.searchName(question) #result = OH870.new #withoutTags = website.strip_tags #result.loadNew(withoutTags) end </code></pre> <p>Now I'm not sure whether there's a way of "asking watir to follow through to the companysearch.php page and dump the results without having to pass this page as a variable. </p> <p>I wonder if anyone has any suggestions here? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload