Page 1 of 1

Grabing photos and item descriptions in ebay

Posted: Mon Feb 20, 2012 9:22 am
by Kasper
Hi,

I am trying to find a particular item "silk tie" in ebay.com and wish to generate a list of which have the item numbers, seller ID and also grap the item photos to C:\finditem\tie\. In that way, I can save time from clicking each searched pages one by one. Could you help me in preparing that script?

Thanks and Regards,

Re: Grabing photos and item descriptions in ebay

Posted: Mon Feb 20, 2012 8:36 pm
by Support
ok. so you need a script that will search for "something" and for each items displayed, you need to download all the photos for that item, and save the item number and seller ID. In other words, build a text file with the item number, seller ID amd picture(s) name one line per item, all fileds tab delimited?

Re: Grabing photos and item descriptions in ebay

Posted: Tue Feb 21, 2012 4:30 am
by Kasper
Yes, that's correct. Thanks for your help.

Re: Grabing photos and item descriptions in ebay

Posted: Wed Feb 22, 2012 1:23 am
by Kasper
By the way, can I have the script for that?

Thanks

Re: Grabing photos and item descriptions in ebay

Posted: Wed Feb 22, 2012 10:44 am
by Support
I'm working on it.

Re: Grabing photos and item descriptions in ebay

Posted: Wed Feb 22, 2012 1:13 pm
by Support
Here is the script. Just change the first line to whatever keywords you want to search for. The tab delimited file will be saved as ebay.txt in the same folder as this script, and the pictures will be saved in the images folder also in the same folder as this script. The first field is the seller ID, then the item number, then the image file name...

Code: Select all

Keywords = 'silk tie';

PerlRegEx = Yes;
Output.Clear;

Link = New(URL);
temp = New(URL);
rx = New(RegEx);
sx = New(RegEx);
F = New(File);
D = New(File);

D.Open(ScriptPath+'ebay.txt');
D.Truncate;

Keywords.Replace('\s', '+');

NextPage = 'http://www.ebay.com/sch/i.html?_nkw='+Keywords+'&_ipg=200&_sacat=See-All-Categories';

while NextPage do begin

	Link.Get(NextPage);
	NextPage = Decode(WildGet(Link.Data, '<a href="([^"]+_pgn=\d+)"[^>]*><i>Next</i>'));
	if NextPage then NextPage = Link.FixUp(NextPage);

	rx.Data = Link.Data;
	rx.Mask = '<a title="[^"]*" href="([^"]+)" class="[^"]*" r="[^"]*" _sp="[^"]*">';
	rx.Reset;

	while rx.Match do begin
		lnk = Link.FixUp(Decode(rx.Value[1]));
	  ItemNumb = WildGet(lnk, '/itm/[^/]+/([^\?]+)');
		temp.Get(lnk);
		SellerID = WildGet(temp.Data, '<a\s+title="Member\s+id\s+([^"]+)"');
		sx.Data = temp.Data;
		sx.Mask = 'image"\s+content="([^"]+\.jpg)"';
		sx.Reset;
		if sx.Match then begin
			lnk = Decode(sx.Value[1]);
			DecodeURL(lnk, [imgID], [FileName]);
			imgID.Replace('\*', '');
			imgID.Replace('\|', '');
			imgID.Replace('\\', '');
			imgID.Replace('\/', '');
			imgID.Replace('\:', '');
			imgID.Replace('\"', '');
			imgID.Replace('\<', '');
			imgID.Replace('\>', '');
			imgID.Replace('\?', '');
			imgID.Replace('\$', '');
			temp.Get(lnk);
			F.Open(ScriptPath+'images\'+imgID);
			F.Write(temp.Data);
			F.Close;
		end else
		  imgID = '';
    DataLine = SellerID +tab+ ItemNumb +tab+ imgID;
    Output(DataLine);
    D.Write(DataLine+crlf);
	end;

end;

D.Close;

Re: Grabing photos and item descriptions in ebay

Posted: Sat Feb 25, 2012 11:31 pm
by Kasper
Thanks very much for your help. I have tested it and it is really amazing.