projects
/
tclrobot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
46c1f79
)
Fix check for content-type
ZMBOT.0.1
author
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 13 Jan 2003 13:59:07 +0000
(13:59 +0000)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Mon, 13 Jan 2003 13:59:07 +0000
(13:59 +0000)
dcdot.tcl
patch
|
blob
|
history
diff --git
a/dcdot.tcl
b/dcdot.tcl
index
3b2edcb
..
8e15fea
100755
(executable)
--- a/
dcdot.tcl
+++ b/
dcdot.tcl
@@
-1,5
+1,5
@@
#!/usr/bin/tclsh
#!/usr/bin/tclsh
-# $Id: dcdot.tcl,v 1.4 2000/12/11 17:11:03 adam Exp $
+# $Id: dcdot.tcl,v 1.5 2003/01/13 13:59:07 adam Exp $
#
proc RobotRestart {} {
#
proc RobotRestart {} {
@@
-10,15
+10,23
@@
proc RobotRestart {} {
proc RobotTextHtml {url} {
global URL
proc RobotTextHtml {url} {
global URL
-
+
set b $URL($url,buf)
set b $URL($url,buf)
- set e {<[mM][eE][tT][aA][^>]*>}
+ set e {<meta[^>]*>}
catch {unset $URL($url,meta)}
catch {unset $URL($url,meta)}
- while {[regexp -indices $e $b i]} {
+ while {[regexp -nocase -indices $e $b i]} {
set meta [string range $b [lindex $i 0] [lindex $i 1]]
lappend URL($url,meta) $meta
set b [string range $b [lindex $i 1] end]
}
set meta [string range $b [lindex $i 0] [lindex $i 1]]
lappend URL($url,meta) $meta
set b [string range $b [lindex $i 1] end]
}
+ set b $URL($url,buf)
+ set e {<title>[^>]*>}
+ catch {unset $URL($url,meta)}
+ while {[regexp -nocase -indices $e $b i]} {
+ set title [string range $b [lindex $i 0] [lindex $i 1]]
+ lappend URL($url,title) $title
+ set b [string range $b [lindex $i 1] end]
+ }
}
proc Robot200 {url} {
}
proc Robot200 {url} {
@@
-74,11
+82,12
@@
proc RobotReadHeader {url sock} {
regexp {^HTTP/([0-9.]+)[ ]+([0-9]+)} $headbuf x version code
set lines [split $headbuf \n]
foreach line $lines {
regexp {^HTTP/([0-9.]+)[ ]+([0-9]+)} $headbuf x version code
set lines [split $headbuf \n]
foreach line $lines {
- if {[regexp {^([^:]+):[ ]+(.*)} $line x name value]} {
+ if {[regexp {^([^:]+):[ ]+([^;]*)} $line x name value]} {
set URL($url,head,[string tolower $name]) [string trim $value]
}
}
set URL($url,state) skip
set URL($url,head,[string tolower $name]) [string trim $value]
}
}
set URL($url,state) skip
+ puts "code=$code"
switch $code {
200 {
if {![info exists URL($url,head,content-type)]} {
switch $code {
200 {
if {![info exists URL($url,head,content-type)]} {
@@
-173,6
+182,11
@@
if {$argc == 1} {
puts $m
}
}
puts $m
}
}
+ if {[info exist URL($url,title)]} {
+ foreach m $URL($url,title) {
+ puts $m
+ }
+ }
foreach v [array names URL $url,head,*] {
puts "$v = $URL($v)"
}
foreach v [array names URL $url,head,*] {
puts "$v = $URL($v)"
}