How to download a .gif file using perl.

Discussion in 'Perl Misc' started by Qing, Jul 31, 2006.

  1. Qing

    Qing Guest

    I need to download lots of .gif files from a website by using perl. But
    the following code doesn't work. Can anybody help?

    use warnings;
    use strict;
    use POSIX 'strftime';
    use LWP::Simple;

    getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    'pg1S.gif');
    Qing, Jul 31, 2006
    #1
    1. Advertising

  2. Qing

    Guest

    Qing <> wrote:
    > I need to download lots of .gif files from a website by using perl. But
    > the following code doesn't work. Can anybody help?


    > use warnings;
    > use strict;
    > use POSIX 'strftime';
    > use LWP::Simple;


    > getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    > 'pg1S.gif');


    'Doesn't work'? In what way does it not work?

    Axel
    , Jul 31, 2006
    #2
    1. Advertising

  3. Qing

    Paul Lalli Guest

    Qing wrote:
    > I need to download lots of .gif files from a website by using perl. But
    > the following code doesn't work. Can anybody help?


    There's a fairly obvious set of debugging steps one should take in this
    situation. Can you please tell us what steps you've taken to debug
    your problem, so that no one here is duplicating your effort?

    Paul Lalli

    [Code retained below for informational purposes]

    > use warnings;
    > use strict;
    > use POSIX 'strftime';
    > use LWP::Simple;
    >
    > getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    > 'pg1S.gif');
    Paul Lalli, Jul 31, 2006
    #3
  4. Qing

    Qing Guest

    The file got downloaded, but not the right size, so the .gif file
    couldn't be opened.
    The correct file size should be 34kb, the downloaded (using perl)file
    size is only 13kb.


    Paul Lalli wrote:
    > Qing wrote:
    > > I need to download lots of .gif files from a website by using perl. But
    > > the following code doesn't work. Can anybody help?

    >
    > There's a fairly obvious set of debugging steps one should take in this
    > situation. Can you please tell us what steps you've taken to debug
    > your problem, so that no one here is duplicating your effort?
    >
    > Paul Lalli
    >
    > [Code retained below for informational purposes]
    >
    > > use warnings;
    > > use strict;
    > > use POSIX 'strftime';
    > > use LWP::Simple;
    > >
    > > getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    > > 'pg1S.gif');
    Qing, Jul 31, 2006
    #4
  5. Qing

    Paul Lalli Guest

    [Top-quoting fixed. Please don't do that. Type your reply *below* the
    material you are quoting, after snipping signatures and other
    irrelevant bits.]

    Qing wrote:
    > Paul Lalli wrote:
    > > Qing wrote:
    > > > I need to download lots of .gif files from a website by using perl. But
    > > > the following code doesn't work. Can anybody help?

    > >
    > > There's a fairly obvious set of debugging steps one should take in this
    > > situation. Can you please tell us what steps you've taken to debug
    > > your problem, so that no one here is duplicating your effort?
    > >
    > > Paul Lalli
    > >
    > > [Code retained below for informational purposes]
    > >
    > > > use warnings;
    > > > use strict;
    > > > use POSIX 'strftime';
    > > > use LWP::Simple;
    > > >
    > > > getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    > > > 'pg1S.gif');

    > The file got downloaded, but not the right size, so the .gif file
    > couldn't be opened.
    > The correct file size should be 34kb, the downloaded (using perl)file
    > size is only 13kb.


    So, the answer to my actual question - What steps have you taken to
    debug your problem? - seems to be: "I tried the code, and saw that the
    sizes are different. Then I posted to Usenet." Is that accurate?

    Please TRY to debug your own problem!
    * Capture the return value of the call to getstore()
    * Check if it was a successful call
    * Try going to the URL manually, and seeing if the file downloads
    successfully in your own browser
    * If the URL is to a server you have access to, check that server's
    logs

    Once you make an attempt at solving your own problem, and demonstrate
    that you are putting effort into it, you will likely receive better
    help from forums such as this one.

    Also, please read (and follow) the Posting Guidelines for this group.
    They are posted here twice a week.

    Paul Lalli
    Paul Lalli, Jul 31, 2006
    #5
  6. Qing

    Mumia W. Guest

    On 07/31/2006 03:35 PM, Qing wrote:
    > Paul Lalli wrote:
    >> Qing wrote:
    >>> I need to download lots of .gif files from a website by
    >>> using perl. But the following code doesn't work. Can
    >>> anybody help?

    >> There's a fairly obvious set of debugging steps one
    >> should take in this situation. Can you please tell us
    >> what steps you've taken to debug your problem, so that no
    >> one here is duplicating your effort?
    >>
    >> Paul Lalli
    >>
    >> [Code retained below for informational purposes]
    >>
    >>> use warnings; use strict; use POSIX 'strftime'; use
    >>> LWP::Simple;
    >>>
    >>> getstore('http://websiteMainpageURL/picshow.asp?dir=Vocab7-9&page=pg1S.gif',
    >>> 'pg1S.gif');

    >
    > The file got downloaded, but not the right size, so the
    > .gif file couldn't be opened. The correct file size should
    > be 34kb, the downloaded (using perl)file size is only 13kb.
    >


    [ top posting fixed ]

    Look in the file, and you might discover that's it's an HTML
    error message saying you don't have permission to access that
    file.
    Mumia W., Jul 31, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hb
    Replies:
    6
    Views:
    9,110
  2. Ryan Taylor
    Replies:
    2
    Views:
    925
    Ryan Taylor
    Nov 10, 2004
  3. dr
    Replies:
    1
    Views:
    326
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Feb 19, 2007
  4. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    738
    Jonathan N. Little
    May 30, 2008
  5. Bergamot
    Replies:
    0
    Views:
    443
    Bergamot
    May 30, 2008
Loading...

Share This Page