Re: scripting an interactive web page

Daniel Pittman <[email protected]> Tue, 13 Apr 2010 10:05:25 +1000
Newsgroups gmane.org.user-groups.slug.chat
Message-ID <[email protected]>
"Voytek Eymont" <[email protected]> writes:
> On Mon, April 12, 2010 5:36 pm, Daniel Pittman wrote:
>> "Voytek Eymont" <[email protected]> writes:
>
>>> how can I get rid of all lines starting with ' INT' ?
>>
>> The GNU Awk documentation should be helpful in solving this sort of
>> problem generically, for the future:
>> http://www.gnu.org/manual/gawk/gawk.html
>
>> (Also, if awk doesn't cut it, Perl, Python, and Ruby all have reasonable
>> support for more complex versions of the same.)
>
>> My approach would be to reconsider how I was getting the input and see if
>>  I could improve pre-processing by, for example, parsing the HTML and
>> emitting the content I actually wanted.
>>
>> Alternately, you could just avoid printing any line that matched that
>> pattern, but I suspect this won't be the last additional requirement you
>> find...
>
> I get a page with one or more items, each items has several lines, one
> line in each item is definitely unneeded, so I guess 'avoid the match'
> will be the go
>
> links -dump crc.html > a.txt
> awk '$1 !~ /(^$)/' a.txt  > a.ful
> awk '/Page/, /References/  { print }' a.ful  > a

...that works.  IIRC, some versions of awk also support the '/Page/ && $1 ...'
syntax, but I confess that I don't know which — by that point I usually have
Perl in hand.

> yes, I'm now thinking 'if I could make a vcal file out of this, that would
> be even nicer...'
>
> are you aware of any tools to convert to 'Title Case' ?

    perl -n -e 'print ucfirst'

> I see plenty options to convert upper/lower case, but haven't found any for
> Title Case

Seriously, by that stage I would be treating this as a reason to pick up a
more capable language and use that.  For example, there are [iv]Cal modules
for Perl that you can push the data into, and which will emit correct XML for
other applications to consume.

Much easier than hand-hacking it, then discovery you need to entity-encode
bits, then that you need a CDATA section in the PCDATA, then...

        Daniel

Any other scripting language is probably about as good, of course.  I just
happen to prefer Perl.
-- 
✣ Daniel Pittman            ✉ [email protected]            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons
-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html