28 lines
797 B
CoffeeScript
28 lines
797 B
CoffeeScript
# Success: Working model on using PhantonJS to get results from pages
|
|
phantom = require 'phantom'
|
|
|
|
# Creates one process
|
|
phantom.create (ph) ->
|
|
# Creates on page
|
|
ph.createPage (page) ->
|
|
URL = "http://www.mdscollections.com/cat_mds_accessories.cfm"
|
|
page.open URL, (status) ->
|
|
console.log "opened page? ", status
|
|
someFunc = (aaa) ->
|
|
attribute_to_want = aaa
|
|
h2Arr = []
|
|
results = document.querySelectorAll(attribute_to_want)
|
|
for x in [0...results.length]
|
|
h2Arr.push(results[x].href)
|
|
return {
|
|
h2: h2Arr
|
|
aaa: this.aaa
|
|
sample_dom: results[0]
|
|
}
|
|
|
|
finishedFunc = (result) ->
|
|
console.log result
|
|
ph.exit()
|
|
|
|
page.evaluate someFunc, finishedFunc, '.listing_product_name'
|