blob: 234672789f902e0d49c27b824992fa4602c43a47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
jsdom = require 'jsdom'
util = require 'util'
fs = require 'fs'
hal = "http://haltools.inrialpes.fr/Public/afficheRequetePubli.php?auteur_exp=Friggeri&CB_auteur=oui&CB_titre=oui&CB_article=oui&langue=Anglais&tri_exp=annee_publi&tri_exp2=typdoc&tri_exp3=date_publi&ordre_aff=TA&Fen=Aff"
jsdom.env hal, ['http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'], (err, window) ->
$ = window.$
types = []
entries = {}
type = null
$('#res_script').children().each ->
$this = $(this)
switch this.nodeName.toLowerCase()
when 'p'
switch $this.attr('class')
when 'Rubrique'
year = $this.text()
when 'SousRubrique'
type = $this.text()
if types.indexOf(type) == -1
entries[type] = []
types.push(type)
when 'dl'
cur = null
entry = {year}
$this.children().each ->
$this = $(this)
switch this.nodeName.toLowerCase()
when 'dt'
switch $this.text().toLowerCase()
when 'auteurs' then cur = 'authors'
when 'détail' then cur = 'more'
when 'titre' then cur = 'title'
else cur = null
when 'dd'
if cur
if cur == 'authors'
entry[cur] = $this.text().split(';').map((s)->s.replace(/^\s*|\s*$/g, ''))
else
entry[cur] = $this.text().replace(/\[|\]/g, '')
entries[type].push(entry)
buf = []
for type, items of entries
buf.push " \\subsection*{#{type.toLowerCase()}}"
for entry in items
buf.push " \\btitle{#{entry.title}}"
buf.push " \\bauthors{#{entry.authors.join(', ')}}"
buf.push " \\bmore{#{entry.more}}"
fs.writeFile __dirname+"/biblio.tex", buf.join('\n'), 'utf8', ->
console.log "Generated biblio.tex"
|