Google Answers Logo
View Question
 
Q: PERL question: using LWP and HTML::Form to submit to eBay ( No Answer,   0 Comments )
Question  
Subject: PERL question: using LWP and HTML::Form to submit to eBay
Category: Computers > Programming
Asked by: dirthurts-ga
List Price: $10.00
Posted: 18 Jul 2002 15:55 PDT
Expires: 17 Aug 2002 15:55 PDT
Question ID: 42677
I'm working on some code to automate posting auctions to eBay. I'm
using LWP, HTTP::Request, HTTP::Cookies, and the "click" method of
HTML::Form to click through the various pages of their new "Sell Your
Item 2.0" form. The code works great for most categories, but there
are some categories (Men's Clothing, Tickets & Travel, etc...) that
have a few extra options like Size, Color, State, # of tickets that
are presented in javascript-enabled drop downs. Unfortunately, when my
code gets to this stage, it appears to get a blank page in return when
I use the click method on the button in the form. I won't post the
whole script here because there are different options added depending
on where in the process it is, but this should be a reasonable
snippet:


use LWP; 
use HTTP::Request::Common; 
use HTTP::Cookies; 
use HTML::Form;
.
.
.
my $ua = LWP::UserAgent->new; 
$ua->cookie_jar(HTTP::Cookies->new(file=>'lwp-cookies',autosave=>1));
# trying to fake a compatible browser, but doesn't work either!
$ua->agent("Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)");  
.
.
.
my @form = HTML::Form->parse($html, $base_uri);
if ($hash{"Category1"}) {
    $form[0]->value(category1 => $hash{"Category1"} ) ;
}
my $req = $ua->request($form[0]->click("buttoncontinue"));
my $html =  $req->content;

Does anyone see anything fishy in this code that would cause it to die
when it sees some javascript or anything like that? If anyone would
like the complete script to look at, let me know...
Many Thanks in advance! 

dirthurts

Request for Question Clarification by webadept-ga on 18 Jul 2002 20:57 PDT
Is there a reason you are using the click method instead of simply
sending the form data strait to the engine? I've written one of these,
and it was pretty straight forward. You click method will probably not
work, since information is passed with each form on the page, you are
apparently not doing this. Not doing this will stall the program.

The best way is to address the engine on a one on one basis. There are
three basic pages you have to go through. The first one gives you back
a unique id and must be passed along on the next form answer, the
second page does the same thing. Read the source of the page and go
direct.

webadept-ga

Clarification of Question by dirthurts-ga on 18 Jul 2002 23:59 PDT
I am using the click method because I don't want to have to worry
about eBay changing their form fields, and I don't want to have to
assign something to every field if I don't have to.  I don't know if
you've seen the newest eBay 2.0 sell your item form but it is a
monster!  It's about 7 or 8 steps as opposed to the original 2-3 step
form.  But you have given me the idea, so maybe I will try to do it
that way and see if I have more success.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy