in reply to Re: fetch url
in thread fetch url

Thank you for the reaction.
Sorry if it isn't clear. (first time you know)

Let I put it this way:
I have a "start_page" with +/- 100 urls on it.
When I hit one of these url's, i would like to go to the url
(could be www.perlmonks.org), and I would like to log in a file that "www.perlmonks.org" was viewed.
input to load the "start_page" (.conf file):

desc,url,hitcounts
nu,http://www.nu.nl,0
cvs,http://www.cvshome.org/,1
perl tutorial,http://www.steve.gb.com/perl/index.html,4

Than i'm able to count with that url.
Than i'm able to add 1 to "hitcounts".

Replies are listed 'Best First'.
Re^3: fetch url
by dorward (Curate) on May 27, 2005 at 12:32 UTC

    Don't worry about it. You clearly put some effort into describing the problem, and given that you are in the Netherlands, I'm guessing English isn't your first language. Its laziness that most people hate around here. We don't mind helping you refine a question if you put the effort in.

    First I would suggest that you use a Real Database instead of a CSV file. I would suspect that using a CSV file could lead to file locking and efficiency issues. That said, you can use the DBI interface to CSV which looks like it solves the file locking problem. I've never used it myself, so I can't be certain it would work nicely.

    As for the actual problem - when the user clicks on their link, their browser will go to it. If that link goes to a different server, the browser won't send any information back to your server so you can't know that they clicked on that link.

    The solution is to have the link point to your server, log the request, and then perform an HTTP redirect.

    To do this you have your script change:

    <a href="http://www.cvshome.org/">CVS</a>

    To:

    <a href="my.cgi?gotoSite=1">CVS</a>

    Where 1 is a unique identifier for the link. You then look up that entry in the database (in my.cgi), log the visit, then redirect (the CGI.pm perldoc tells you how) to the URL stored in your database.

    You should use identifiers and database lookups rather then that URL itself for two main reasons. First, it prevents people using your domain to cloak their dodgy URL, and second it saves you from the effort of having to URL Encode and HTML Encode the string when you generate the webpage.

      Your feedback is overwhelming, thank you for that

      After a couple of days searching i didn't know that i should have look for a syntax like you mentioned
      I was searching the wrong direction
      Thank you also for the extra tips
      So i have a lot of homework now

      Must I close this question in some way, or do i have to do something else to keep things surveyable ?

      Kind regards,
      The Perlboer

        You're very welcome.

        No, you don't need to do anything to close a question (although a feature allowed people to mark questions as resolved has been suggested in the PerlMonks Discussion section in the past).