in reply to Count of articles Google News

If you attempt to reach the address on Line 31 by pasting it into your browser's address bar, you may see the underlying problem; the timing problem is that your "after a while" (a term of very low precision) may reflect the time burned in the loops at Lines 27-29.

Additionally:

updated: Reordered phrases in bullet #1, for clarity.



Replies are listed 'Best First'.
Re^2: Count of articles Google News
by madsoeni (Initiate) on Mar 01, 2015 at 11:25 UTC
    Dear www, thanks for your reply. I couldn't see the problem by pasting the address, could you please be more clear about this? I can't see why it is not working... I put that address because with the tbm = nws the address is returning the search results for the news. Finally, what do you mean by the "odd formatting? Thank you!

      NB: This applies to your next reply, as well as to the above... and, I hope, provides some insight on how better to obtain the assistance you seek.

      Please provide exact output; not vague descriptions when you say you've tried to understand a reply from a Monk. "I couldn't see... does NOT tell us what you DID see. Since my understanding of your problem may be defective, you need to tell us specifics.

      Gimmé ("give me...") questions like "what do you mean" are less than welcome: The Monastery's mission is to help you (and others with questions) learn how to solve problems. I meant that the indenting obscures the structure of your code, but this an issue about which you might have garnered a clue by reading some other code rather than merely asking someone to spoon-feed you an answer.
      Similarly, from your next reply, "...I basically need to change the address from which I am doing the requests in the script, isn't it? Would you be so kind to tell me where I could find some examples of this?" reflects no effort on your part represents a pair of "gimmés.

      Please read On asking for help and How do I post a question effectively?; visit the Tutorials section; and -- not least of all -- try some self-help, even if it results only in better-framed questions.

      And since you describe yourself as "real newbie in Perl," you may wish to start by coding solutions to the exercises in something like Learning Perl (commonly also available from other vendors, including used-book emporia) or working thru one of the (many) on-line courses that are made freely available from university-level CS programs.

      Update (forgot to mention this earlier):  Among the practices to adopt early: use strict; -- always, until you know a truly good reason to omit the stricture. Doing so will let Perl itself point out many mistakes, such as those that exist in your code. Correcting those that pop up initially (failure to declare variables with my... and company) will lead to your discovery of several more problems whose resolution will also move you forward to the pont where your code will actually start to produce the results you seek:

      Data will save to data_uk.txt Search term is hello. Number of results 1-1-2012 : 8050 Can't use string ("data_uk.txt") as a symbol ref while "strict refs" i +n use at 1118172.pl line 67.

      At the point in debugging where the code produces the above result, there's still "fixing" to be done ... but by the time you get there, you should be able to complete the repairs.


      ++$anecdote ne $data


      Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
      1. code
      2. verbatim error and/or warning messages
      3. a coherent explanation of what "doesn't work actually means.
        Dear WW, I perfectly understand your point, I did not make so much effort in looking for an answer by myself and I was wrong in doing this. You are also right in your suggestion about including the  use strict;, yet it seems strange to me that - by including this - not even the code provided by the professor is working. I will try to go over the tutorials at first, thanks for you help, it will be useful! About bing, I figured out that results cannot be really sorted by date as in Google, hence making it not really useful for my purpose (I would rather have a news index by country and date, which is not permitted by bing), but it was still worth to give it a try!