Skip to content

Instantly share code, notes, and snippets.

@Oldes
Last active November 4, 2015 13:21
Show Gist options
  • Save Oldes/c1da3423ee7156050799 to your computer and use it in GitHub Desktop.
Save Oldes/c1da3423ee7156050799 to your computer and use it in GitHub Desktop.
REBOL [
Title: "M_fleda"
Date: 6-Jan-2005/18:46:29+1:00
Author: "oldes"
require: [
;rs-project 'brno_kalendar
]
]
init-misto "fleda"
insert db "SET NAMES 'utf8'"
m_fleda: context [
rok: now/year
typ: "klub"
digits: charset "1234567890"
spaces: charset " ^-^/^M"
parse-program: func[html /local tmp denstart denkonec zacatek interpret nazev autor rezie popis detail_url id_orig mistoup poznamka typ_orig prev-month pstart pend][
prev-month: 0
parse/all html [
any [
(
pstart: pend: none
denstart:
denkonec:
zacatek:
id_orig:
typ_orig:
interpret:
nazev:
autor:
rezie:
popis:
detail_url:
id-mista:
mistoup:
poznamka:
typ_orig:
none
)
thru {<div class="program-item-imag"}
thru {http://fleda.cz/css/img/} copy typ_orig to {.gif'}
thru {<div class="program-item-capt">}
thru {href="http://fleda.cz/program/} copy id_orig to {"}
thru {<span class="program-item-time">} copy denstart to {<}
thru {<h2>} copy nazev to {</h2}
thru {<div class="program-item-body">} copy popis to {</p><a}
(
if find id_orig "?" [parse/all id_orig [copy id_orig to "?" to end]]
denstart: to-date trim/all denstart
detail_url: join http://fleda.cz/program/ id_orig
if string? popis [
parse popis [thru "<p style=" thru {>} copy interpret to {</p} thru {>} copy popis to end]
popis: remove-tags/base popis http://www.fleda.cz/
]
interpret: remove-tags interpret
typ: switch/default typ_orig [
"hudba" ["klub"]
"divadlo" ["divadlo"]
"kino" ["kino"]
]["klub"]
;probe id_orig
;print [typ_orig id_orig]
vloz-akci
;probe
reduce [
denstart
denstart
zacatek
interpret
nazev
autor
rezie
popis
detail_url
id_orig
mistoup
poznamka
typ_orig
typ
]
wait 0.1
)
]
]
]
]
;m_fleda/parse-program read %/g/programy/fleda_2006_2.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment