This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

download a html file

Help for those learning Tcl or writing their own scripts.
Post Reply
B
BlinK_
Voice
Posts: 4
Joined: Fri Nov 18, 2005 11:46 am

download a html file

Post by BlinK_ »

Hello. How to download a file, in ex: http://somesite.some/somefile.html to the eggdrop dir. Later i want to extract some notes from it. But i asume learning how to download it wuold be a best start.. Thank you.
User avatar
]Kami[
Owner
Posts: 590
Joined: Thu Jul 24, 2003 2:59 pm
Location: Slovenia
Contact:

Post by ]Kami[ »

Well, you could do it with shell command, but u need to have wget installed :P

Code: Select all

catch {exec wget http://somesite.some/somefile.html}
file rename -force somefile.html /home/you/eggdrop/somefile.html
r
rayman
Voice
Posts: 4
Joined: Fri Nov 18, 2005 7:48 am
Location: Germany

Post by rayman »

Or you can use lynx (if installed)

Code: Select all

exec lynx -dump http://www.somesite.com/somepage.html >somefile.tmp
Greetz
rayman
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

neither of these will work on Windows (windrop), nor will they help you later in parsing

you should use Tcl's built-in http package:

Code: Select all

package require http
set token [::http::geturl http://foo.com/bar.html]
# save it to file
set f [open bar.html w]
fconfigure $f -translation binary
puts -nonewline $f [::http::data $token]
close $f
# or parse it
foreach line [split [::http::data $token] \n] {
   # parse that line
}
::http::cleanup $token
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
B
BlinK_
Voice
Posts: 4
Joined: Fri Nov 18, 2005 11:46 am

Post by BlinK_ »

thank you for help. Will demonds script overwrite bar.html file if it already exist?

And i get an error while running this script in tclpro :

http://k.1asphost.com/pbatm/error.jpg

And i want to do a Half life server browser dcript. So i know the website witch gives information of specified servers. So i download html file to the eggdrop dir. Extract some info. And post it to the chan. Maybe there is some easyer way to do this? Maybe there is some scripts already done? I searched this tcl archive and found nothing. Then I googled a lot.. And still nothing...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

not a script problem, your installation's problem

learn to copy & paste text, no need to post pictures of text; and learn how to use http package (I somehow doubt you have any experience in scripting though...)

there are zillions of http scripts which do what you want to do; how did your search yield nothing is beyond me
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
B
BlinK_
Voice
Posts: 4
Joined: Fri Nov 18, 2005 11:46 am

Post by BlinK_ »

of course i have no exp in tcl scripting. that is why i'm asking help.
Post Reply