Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Adding Products automation

by perleager (Pilgrim)
on Oct 26, 2004 at 20:18 UTC ( [id://402790]=perlquestion: print w/replies, xml ) Need Help??

perleager has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm helping a friend out by helping him set up a few internet shops. We are using oScommerce (a php open source shopping cart) and I would like to program a script that automates our product adding.

If I was to do this MANUALLY!!!!!!!!
Lets say we are going to have 500+ products for these websites, that means I'll have to manually:

  • goto each product url
  • start typing/copying pasting the descriptiong for product
  • insert price
  • save image/upload image
  • update product listing.

    Now if I made a perl script to automate process:

    Have LWP retrieve page by having product url ( a simple text file list with 100 different product urls, that way I can use a foreach statement and have LWp retrieve each url by url)
  • Parse description from product url page.
  • save image/uplaod image (*Is this possible?)
  • use DBI module to update mysql DB for each product listing (instead of having to use the oScommerce admin interface to add product info)

    Basically what im trying to do is make a script that automates this process I would have to go through If i was to add each product detail manually to the shopping cart DB.

    About the saving images, I wanted to save a product image from a another website to my server. Is that possible??
    When parsing the website with the product image I want to retrieve, it'll look for the image file name.

    Thank you,
    Anthony
  • Replies are listed 'Best First'.
    Re: Adding Products automation
    by jarich (Curate) on Oct 27, 2004 at 01:14 UTC
      About the saving images, I wanted to save a product image from a another website to my server. Is that possible?? When parsing the website with the product image I want to retrieve, it'll look for the image file name.

      Saving the image is easy so long as you can find it in the HTML source. I'll presume that you're willing to either use a HTML parser or that you know where the images are stored before hand. If this is the case then all you need to do is something like this:

      #!/usr/bin/perl -w use LWP::Simple; use strict; my $image = getstore("http://www.perltraining.com.au/images/logo.png", "/tmp/logo.png") or die "no content?";

      This gets the logo.png image from the perltraining.com.au website and stores it in your tmp directory. You will need to change that directory if you are on a Windows box.

      Once you've saved the image then you'll need to work out what to do with it. Some e-commerce sites store the whole image in the database in blob format (heaven forbid) and others more sensibly store the filename.

      Make sure that you scrutinise how oScommerce works with the database. In particular, if oScommerce is using InnoDB tables in MySQL then you should take advantage of that and use transactions in your code.

      I've avoided the potential legal issues here. Make sure you have the right to copy those images and use them in your site. :)

      I hope this helps.

      jarich

        Hello,
        thank you all for replyin.

        Jarich, I think you understood my problem more and basically gave me what I needed to finish up this script. I never knew about the getstore command and how it can download a image to the tmp directory like that. Now that you gave me that example, I'm well on my way on finishing it. About the image being stored as a blob on the db, heck no =). I'll be parsing the image file name from the image url and store its filename in the db. And about the legal issue, the product images / info I'll be stealing is from my distributor main website which allows its retail members to use for such purposes. =)

        Anthony
    Re: Adding Products automation
    by jfroebe (Parson) on Oct 26, 2004 at 20:39 UTC

      Hi Anthony

      Yes, it is possible. Are you having a problem with any particular part or are you just asking if your reasoning is sound?

      Jason L. Froebe

      Team Sybase member

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

    Re: Adding Products automation
    by thor (Priest) on Oct 26, 2004 at 22:17 UTC
      I know next to nothing about mysql, but does it have some sort of bulk data loading utility? If so, you could use that to insert directly into your database. Create a bunch of delimited files and away you go...

      thor

      Feel the white light, the light within
      Be your own disciple, fan the sparks of will
      For all of us waiting, your kingdom will come

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://402790]
    Approved by atcroft
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others sharing their wisdom with the Monastery: (7)
    As of 2024-04-19 09:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found