Gossamer Forum
Home : Products : Links 2.0 : Customization :

Widgetz, I'm assuming you can do this, any ideas?

Quote Reply
Widgetz, I'm assuming you can do this, any ideas?
Um, i'm using my lwp url checker mod and i also want it to store size like altavista. I think since with my lwp mod, all I have to do is put in this after it opens the new HTTP::Request,
$h->content_length. Like i said i wanna store this, like a regular links thing like url i guess, then be able to call it up on the link.html file. Get me? Oh i tried what i said but i don't think it stored it in my new field and i put Size => $size in site_html_templates.pl. I also tried putting $size = $h->content_length but it won't work. Know how?
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
uhh.. i would do it like this:

use LWP::Simple;
$stuff = get($url);

$size = length($stuff);

i don't use those $h->stuff.... cause i don't like them.. the mean.. Smile

jerry
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Ok, I'm going to bed, but i may figure this out if i come back on before you answer it. Its getting the size, bringing it back on the page, but i doesn't write it to the validate database, could this be because i have size only in the sub site_html_add_success and failure pages, besides link.html, is there somewhere else i should put this in site_html_templates.pl, or is it something further.
------------------------------------------
Nevermind i got it, thanks

[This message has been edited by Bmxer (edited September 08, 1999).]
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Ok, something sucks, because the numbers its bringing back are not the real sizes, does that code print in KB. Its printing 40 K for my 2.12 K file. And i check a site from yahoo, that was 5 and it printed 30 something. Do you know why?
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Ok, before, I wasn't doing it right, i was like using useragent, with HTTP Request, but now it prints bytes so could you give me an example of how i would say if Size = > 1024 size = 1++ or something so that 1024 can equal 1, i think 1024 bytes is a kb. Anyway do you know how?
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
oh.. since i have a software dir i use bytes... for everything.. i just have this sub convert it..

Code:
sub filesize {
my $bytes = shift;
my @info = qw!bytes kb mb gb tb!;
my ($i);

while ($bytes > 1024) {
$bytes = int($bytes/1024);
$i++;
}
return "$bytes $info[$i]";
}

and it pretty much divides it and gets the right one.. kb mb or gb.. or bytes..

you use it like this

$scalar = &filesize($scalar);

jerry
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Ok, I have this now
use LWP::Simple;
$stuff = get($URL);

$in{'size'} = &filesize(length($stuff));
As far as i can see it prints the size on add_success and in the v - db, so i guess that was right, thanks for mucho help.

[This message has been edited by Bmxer (edited September 08, 1999).]
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Hi, in which files did you place all the codes??
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
size => $size, in sub site_html_add_success or whatever.

In add.cgi
Code:
use LWP::Simple;
$stuff = get($URL);

$in{'size'} = &filesize(length($stuff));
after this :
Code:
# Validate the form input..
$status = &validate_record(%in);
Then at the bottom
Code:
sub filesize {
my $bytes = shift;
my @info = qw!bytes kb mb gb tb!;
my ($i);
while ($bytes > 1024) {
$bytes = int($bytes/1024);
$i++;
}
return "$bytes $info[$i]";
}
Then of course you'd put size in the sub site_html_link size => $size, if you want to use it next to a link. And you can show the user you got it if you want by putting it in the add_success.html page by calling <%size%>, also make a new field in links.cfg
size => [8, 'numer', 10, 12, 0, '', ''] change the 8 to the last number you have and put it at the bottom. That should be it.
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Widgetz,
I tried using HTML::Headparser to get the title and description and stuff, but it keeps using hypermarts. Do you know how i can use my own? because hypermart doesn't have them. Maybe if i can put my root in the INC but i don't know how.
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
 http://www.pdamania.com/geturl.cgi

??

jerry
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Yeah, i know, wow, i just saw that you put the spider thing on it, and the size thing. Its pretty fast to basically read the whole document. Theres a problem with it though. Its not out yet. I know you have school and all, so i just wanted to test with this until you do release, because i know yours will be better so i would most likely get rid of mine and use yours.
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
i'm changing mine to use sockets instead.. lwp is too slow.. and sockets can figure out when the file was modified..

i pretty much fixed the spider thing just a second ago.. but i can't get my ftp to work Smile

jerry
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Can i have a peek at the code? Smile
litrbf@aol.com

[This message has been edited by Bmxer (edited September 12, 1999).]
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
i'll give you my lwp version soon.. i'll make the sockets version when i have time..

don't except the lwp version until friday though Wink

jerry
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
ok, i'm testing my lwp url checker mod, and adding stuff, and i'm seeing if the redirect thing is working, so it will visit the redirected site, but its hard to tell when for someone using Come.to and their site is 6KB the size thing is printing back 1KB. Do you know how to make that code using simple or whatever also redirect. I tried putting it in my mod, but it always gets a wrong file size. So i want it to get the redirect page, not just the first ones size.
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Hi Bmxer, I tried using the mod you and Jerry created which checks the file size of a submitted URL and prints it on the success page.

I have added a field in links.def called size, but now when I go to add.cgi to submit a URL, it always tells me that I can't leave size empty.

What have I done wrong?


From Paul Wilson.
http://www.audio-grabber.com
Music Directory
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
Paul, I am just guessing but you probably have a field like "size" which looks something like this;
In Reply To:
Size => [14, 'alpha', 10, 50, 1, '', ''],
if you do then try changing "1" to "0" that might help you, I hope this was what you were looking for.


Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
I'll try this thanks!

From Paul Wilson.
http://www.audio-grabber.com
Music Directory
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
I'm using numer, not alpha for size in links.def....but anyway...what does changing the 1 to 0 do?

From Paul Wilson.
http://www.audio-grabber.com
Music Directory
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
On the success page, it always says the file size is 0 bytes - why?

From Paul Wilson.
http://www.audio-grabber.com
Music Directory
Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
changing 1 to 0 changes the required status of that field as far as I know. meaning that if you make the field 0 than that field could be left blank but if you make that 1 than there must be a user entry to that field.

about 0 bytes on the success page, it has to say something so since there is no value thats why it says 0 bytes.

Quote Reply
Re: Widgetz, I'm assuming you can do this, any ideas? In reply to
But i tested it by adding a value to the size field and it still showed up a o bytes!

From Paul Wilson.
http://www.audio-grabber.com
Music Directory