Can someone elaborate as to why this isn't working
coder45
created: 2006-01-01 07:27:33
#! Perl\bin\perl -w

use WWW::Search;


open FILE1, "> url1.txt" or die "$!";

my $oSearch = new WWW::Search('Yahoo::UK');

my $sQuery = WWW::Search::escape_query("world cup 2006");

$oSearch->native_query($sQuery);
  
while ( my $oResult = $oSearch->next_result() ) { 
    print "Adding: ", $oResult->url, "\n";
    print FILE1 $oResult->url, "\n";

I am on activeperl 5.8X, it generates the url1.txt file but it is empty
Re: Can someone elaborate as to why this isn't working
created: 2006-01-01 07:47:42

Running this exact code (with or without strict and warnings enabled) with perl 5.8.4 on Linux works fine, it returns 10 URLs, both at the command line and in the file (WWW::Search version 2.46).

You could try using ethereal to view the traffic and see whether something is wrong there, or turn on the search_debug and search_parse_debug options in native_query.


A computer is a state machine. Threads are for people who can't program state machines. -- Alan Cox
Re: Can someone elaborate as to why this isn't working
created: 2006-01-01 08:22:07
Are you doing a
close(FILE1);
after you have finished writing to the file?

I'm not familiar with activeperl - but is there a chance it's not flushing the output to the file?

(Although I would *expect* Perl to cleanly flush to and then close the filehandle when the script ends!?)

Re^2: Can someone elaborate as to why this isn't working
vek
created: 2006-01-02 03:28:01

serf, good guess but activeperl behaves no differently than Perl on any other box in this regard. The buffer will be flushed and the filehandle closed when the program ends.

-- vek --
Re: Can someone elaborate as to why this isn't working
created: 2006-01-01 12:14:07
This problem, at least on Win32, seems to be with the (older) available WWW-Search and WWW-Search-Yahoo ppm packages. I just placed the most recent versions of these at http://theoryx5.uwinnipeg.ca/ppms/, which seems to fix this.
Re^2: Can someone elaborate as to why this isn't working
created: 2006-01-02 01:12:11
How did you 'replace' them I am a newbie and the option I see seems to install it only, but it says "already installed" for www::search and www;:yahoo
Re^3: Can someone elaborate as to why this isn't working
vek
created: 2006-01-02 03:15:03

coder45, taking a quick peek at the ppm commands yields the following results:

c:\>ppm help
Type 'help command' for more detailed help on a command.
  Commands:
    describe   - describes packages in detail
    exit       - exits the program
    help       - prints this screen, or help on 'command'
    install    - installs packages
    profiles   - manage PPM profiles
    properties - describes installed packages in detail
    q	       - exits the program
    query      - queries installed packages
    quit       - exits the program
    remove     - uninstalls packages
    repository - adds, removes, or sets repositories
    s	       - searches for packages in a repository
    search     - searches for packages in a repository
    settings   - view or set PPM options
    targets    - views or sets target installer backends
    tree       - shows package dependency tree
    uninstall  - uninstalls packages
    unset      - view or set PPM options
    upgrade    - shows availables upgrades for installed packages
    version    - displays the PPM version (3.2)
  Extra Help Topics: (not commands)
    ppm_migration - guide for those familiar with PPM
    prompt	  - how to interpret the PPM prompt
    quickstart	  - a crash course in using PPM
    unicode	  - notes about unicode author names

So you may want to give the following a try:

c:\>ppm upgrade WWW::Search

Update: Hmm, that won't help you out because it will query the activeperl repository. To re-install from Randy's repository, try the following:

c:\>ppm install http://theoryx5.uwinnipeg.ca/ppms/WWW-Search.ppd -force
Note the -force option which will reinstall the package if you already have it installed.

-- vek --
Re^4: Can someone elaborate as to why this isn't working
created: 2006-01-02 09:34:49
I did the force option and upgraded the packages but unfortunately still an empty url1.txt file
Re^5: Can someone elaborate as to why this isn't working
created: 2006-01-02 13:52:05
Does the script print the results to the screen? And are you letting it run to completion? When I run it, it takes a while to complete, as there's a sleep() call in there to prevent the site from thinking you're a robot - if you abort too early, the file indeed may be empty due to buffering. Try getting, say, the first 5 results, and let it run to completion.
Re^6: Can someone elaborate as to why this isn't working
created: 2006-01-03 02:03:35
No results are printed to the screen, the program simply compiles and moves to the comand line prompt after a few seconds, nothing is shown in the url1.txt file. I am out of ideas, I installed all the packages via ppm and as far as I can see everything is working ok, but no results on screen or file.
Re^7: Can someone elaborate as to why this isn't working
created: 2006-01-03 11:43:25
I'd suggest ensuring that the WWW-Search and WWW-Search-Yahoo packages are the most recent ones from the uwinnipeg repository; sometimes upgrading packages via ppm is tricky. Witness the following session of trying to upgrade WWW-Search-Yahoo, having installed it earlier from the ActiveState repository:
ppm> rep
Repositories:
[1] ActiveState Package Repository
[2] uwinnipeg
ppm> rep desc 2
Describing Active Repository 2:
    Name: uwinnipeg
Location:
http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58
    Type: PPMServer 2.0
ppm> upgrade -install WWW-Search-Yahoo
WWW-Search-Yahoo 2.37: new version 2.404 available 
    in uwinnipeg
====================
Upgrade 'WWW-Search-Yahoo' version 2.37 
     in ActivePerl 5.8.7.815.
====================
Downloaded 17256 bytes.
Extracting 17/17: blib/arch/auto/WWW/Search/Yahoo/.exists
Successfully upgraded WWW-Search-Yahoo version 2.37 
    in ActivePerl 5.8.7.815.
Thus, even though ppm saw that an upgraded version was available in the uwinnipeg repository, it didn't upgrade to that version. One way to do that is to uninstall the package, move the uwinnipeg repository ahead of the ActiveState repository, and then install:
ppm> rep up 2
Repositories:
[1] uwinnipeg
[2] ActiveState Package Repository
ppm> remove WWW-Search-Yahoo
====================
Remove 'WWW-Search-Yahoo' version 2.37 from 
    ActivePerl 5.8.7.815.
====================
unlink C:\Perl\html\site\lib\WWW\Search\Yahoo.html
[ snip ]
ppm> install WWW-Search-Yahoo
====================
Install 'WWW-Search-Yahoo' version 2.404 
    in ActivePerl 5.8.7.815.
====================
Downloaded 22629 bytes.
Extracting 45/45: blib
Installing C:\Perl\html\site\lib\WWW\Search\Yahoo.html
[ snip ]
Successfully installed WWW-Search-Yahoo version 2.404 
  in ActivePerl 5.8.7.815.
ppm> upgrade WWW-Search-Yahoo
WWW-Search-Yahoo 2.404: up to date.
You should also do the same for the WWW-Search package.
Re^8: Can someone elaborate as to why this isn't working
created: 2006-01-05 03:52:38
it works now thanks removed www-search and www-search-yahoo and reinstalled it from uwinnipeg

perlmonks.org content © perlmonks.org and coder45, randyk, serf, tirwhan, vek

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03