08-27-周三_17-09-29
This commit is contained in:
30
node_modules/phantom/samples/test_phantom_2.coffee
generated
vendored
Normal file
30
node_modules/phantom/samples/test_phantom_2.coffee
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# Success: Testing for wikipedia
|
||||
phantom = require 'phantom'
|
||||
phantom.create (ph) ->
|
||||
ph.createPage (page) ->
|
||||
page.open 'http://en.wikipedia.org/wiki/Main_Page', (status) ->
|
||||
console.log 'Opened site? %s', status
|
||||
another_funny page, ph
|
||||
|
||||
another_funny = (page, ph) ->
|
||||
# query page for results
|
||||
page.evaluate ->
|
||||
|
||||
# function needs to be within the page evaluate callback
|
||||
funny = ->
|
||||
h2Arr = []
|
||||
results = document.querySelectorAll('p')
|
||||
for x in [0...results.length]
|
||||
h2Arr.push(results[x].innerHTML)
|
||||
return h2Arr
|
||||
|
||||
h2Arr = []
|
||||
pArr = []
|
||||
h2Arr = funny()
|
||||
return {
|
||||
h2: h2Arr
|
||||
}
|
||||
|
||||
, (result) ->
|
||||
console.log result
|
||||
ph.exit()
|
Reference in New Issue
Block a user