Copy this code and paste it in your HTML
import com.gargoylesoftware.htmlunit.WebClient import com.gargoylesoftware.htmlunit.BrowserVersion import com.gargoylesoftware.htmlunit.html.HtmlPage import java.util.regex.Pattern
fh2.
write( "\"Name\",\"Phone\",\"URL\"\n" )
def wc
= new WebClient
( BrowserVersion.
FIREFOX_3 ) wc.
setJavaScriptEnabled( false )
def wcII
= new WebClient
( BrowserVersion.
FIREFOX_3 ) wcII.
setJavaScriptEnabled( false )
def urlString
= "http://www.yelp.com/search/snippet?attrs=&cflt=&find_desc=taxi&find_loc=New+York+NY&mapsize=small&rpp=40&show_filters= 1&sortby=best_match&start=${start}"
def page
= wc.
getPage( urlString
) def jsonContent
= page.
getWebResponse().
getContentAsString().
trim() def jsonObj
= new JSONObject
( jsonContent
) def nameArray
= jsonObj.
names() def valArray
= jsonObj.
toJSONArray( nameArray
);
fh.
write( "<html><body>" + valArray.
getString(0
) + "</body></html>" )
def htmPage
= wcII.
getPage( "file:///tmp/EstherKestenbaum/output.html" ) def divList
= htmPage.
getDocumentElement().
getHtmlElementsByTagName("div") if ( div.
getAttribute("class").
equals("businessresult clearfix") ) { def subDivs
= div.
getHtmlElementsByTagName("div") if ( sub.
getAttribute("class").
equals("leftcol") ) { def aList
= sub.
getHtmlElementsByTagName("a") url = "http://www.yelp.com" + aList[0].getAttribute("href").trim()
name = aList[0].asText().trim()
}
if ( sub.
getAttribute("class").
equals("phone") ) { phone = sub.asText().trim()
}
}
fh2.
append( "\"" + name
+ "\",\"" + phone
+ "\",\"" + url
+ "\"\n" ) }
}
}