🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.tcl
Article #191

Re: parsowanie stron www

#191
From: Artur
Date: Mon, 10 Oct 2005 08:23
33 lines
2043 bytes
Miszczu schrieb:

> Probuje napisac pareser stron www, mam jednak maly klopot, czy istnieje
> jakis prosty sposob zeby z danego kawalka strony pozbyc sie wszystkich
> znacznikow html typu <b> <p> <a href...> itp itd
>
> Fajnie by bylo gdybym mogl to zrobic np poprzez
> string map { <*> "" } $zrodlo
> Ale jakos nie dziala ;)

# Można użyć też tDOM z opcją do HTML o ile to uważa się za
prosty spośób
# http://www.tdom.org

package require tdom
set f [open "my.html" r]
set document [dom parse -html [read $f]]
close $f

# remove all p nodes
foreach node [[$document documentElement] selectNodes */p] {
     # transfer child nodes of p to parent
     foreach c [$node childNodes] {
	 [$node parentNode] insertBefore $c $node
     }
     [$node parentNode] removeChild $node
}

set f [open "my2.html" w]
puts -nonewline $f [[$document documentElement] asHTML]
close $f

# Artur Trzewik
Technical Details
Message-ID: <1128932632.871157.317610@g47g2000cwa.googlegroups.com>
Path: mbox-mo1.pugleaf.net!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail
References: <di5s49$1t7$1@nemesis.news.tpi.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail
From: "Artur" <mail@xdobry.de>
Newsgroups: pl.comp.lang.tcl
Subject: Re: parsowanie stron www
Date: 10 Oct 2005 01:23:52 -0700
Organization: http://groups.google.com
Lines: 34
Message-ID: <1128932632.871157.317610@g47g2000cwa.googlegroups.com>
References: <di5s49$1t7$1@nemesis.news.tpi.pl>
NNTP-Posting-Host: 62.225.37.69
Mime-Version: 1.0
X-Trace: posting.google.com 1128932638 14571 127.0.0.1 (10 Oct 2005 08:23:58 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 10 Oct 2005 08:23:58 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.10) Gecko/20050717 Firefox/1.0.6,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 G8SLV (NetCache NetApp/5.6.2D9)
Complaints-To: groups-abuse@google.com
Injection-Info: g47g2000cwa.googlegroups.com; posting-host=62.225.37.69; posting-account=LCgZWAwAAABJR_8tjAef_hUAajXeKdEF
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit