Skip to content

Instantly share code, notes, and snippets.

@crackcomm
Created April 9, 2013 16:01
Show Gist options
  • Save crackcomm/5346948 to your computer and use it in GitHub Desktop.
Save crackcomm/5346948 to your computer and use it in GitHub Desktop.
html = require './html'
q = require './q'
{sequence} = q
{unpatch} = html
index = 'http://rozklady.mzkjastrzebie.com/index.php?MenuItem=2'
action =
parseUrl: index
domSelect: 'table tbody tr'
map:
extract: [
id: path: 'td:nth-child(1)', get: 'text'
community: path: 'td:nth-child(2)', get: 'text'
stop: path: 'td:nth-child(3)', get: 'text'
lines:
path: 'td:nth-child(4) a'
get: 'map href'
]
slice: [1, 5]
seq = sequence unpatch action
seq.then (res) ->
console.log "End :)", res
End :) [ { id: '1',
community: '',
stop: 'Rydułtowy Bednorz Pętla',
lines: [ 'index.php?LiniaId=193' ] },
{ id: '2',
community: 'CZERWIONKA-LESZCZYNY',
stop: 'Bełk Pętla',
lines: [ 'index.php?LiniaId=131', 'index.php?LiniaId=117' ] },
{ id: '3',
community: 'CZERWIONKA-LESZCZYNY',
stop: 'Bełk Poczta',
lines: [ 'index.php?LiniaId=131', 'index.php?LiniaId=117' ] },
{ id: '4',
community: 'CZERWIONKA-LESZCZYNY',
stop: 'Bełk Palowicka',
lines: [ 'index.php?LiniaId=134' ] } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment