By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,811 Members | 785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,811 IT Pros & Developers. It's quick & easy.

script to search ebay?

P: n/a
Hi all,

Anyone know where I can find a python script to search ebay? I
have been looking around but haven't found anything. I know
there must be one somewhere so I am probably just looking in the
wrong places. Optimally, I would like the script to search ebay
and then send an email out with the results.

Lance
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
This script works. But why not make a 'Favorite Search' in ebay, and
have it send you daily email for a year?

--Kamilche

|import urllib
|import smtplib
|
|def main():
| # Perform the search
| results = SearchEbay(['So long and thanks for all the fish',
| 'NOMATCHFOUND',
| 'Python Programming'])
|
| # Email the results
| Email('m*@somewhere.com',
| 'y**@somewhere.com',
| 'eBay Search Results',
| results)
|
|def SearchEbay(searchstrings):
| ' Search eBay for the desired items'
| searchURL = "http://search.ebay.com/%s"
| results = ""
| s = "eBay Search Results:\n"
| print s,
| results += s
| for i in range(len(searchstrings)):
|
| # Build the search URL
| search = searchstrings[i].replace(' ', '-')
| s = searchURL % search + " : "
| print s,
| results += s
|
| # Download the URL
| url = urllib.urlopen(searchURL % search)
| data = url.read()
| url.close()
|
| # Write the URL to a file for debugging
| fd = open('ebay %d.html' % i, 'w')
| fd.write(data)
| fd.close()
|
| # Search for the number of items found
| c = data.find('items found for')
| if c >= 0:
| start = data.rfind('<b>', 0, c) + 3
| stop = data.find('</b>', start + 1)
| cnt = data[start:stop]
| else:
| cnt = '0'
| s = "%s items found.\n" % cnt
| print s,
| results += s
|
| return results
|
|def Email(fromaddr, toaddr, subject, msg):
| ' Send email'
| msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % \
| (fromaddr, toaddr, subject, msg))
| server = smtplib.SMTP('your.smtp.server.here')
| server.set_debuglevel(1)
| server.sendmail(fromaddr, toaddr, msg)
| server.quit()
|
|main()

Jul 18 '05 #2

P: n/a
Thanks for the script. I haven't been on ebay for a while.
Wasn't aware of the Favorite searches. Favorite Search is
probably the way to go. Thanks for the info.

Lance
On Tue, 25 Jan 2005 22:57:54 -0800, Kamilche wrote:
This script works. But why not make a 'Favorite Search' in ebay, and
have it send you daily email for a year?

--Kamilche

|import urllib
|import smtplib
|
|def main():
| # Perform the search
| results = SearchEbay(['So long and thanks for all the fish',
| 'NOMATCHFOUND',
| 'Python Programming'])
|
| # Email the results
| Email('m*@somewhere.com',
| 'y**@somewhere.com',
| 'eBay Search Results',
| results)
|
|def SearchEbay(searchstrings):
| ' Search eBay for the desired items'
| searchURL = "http://search.ebay.com/%s"
| results = ""
| s = "eBay Search Results:\n"
| print s,
| results += s
| for i in range(len(searchstrings)):
|
| # Build the search URL
| search = searchstrings[i].replace(' ', '-')
| s = searchURL % search + " : "
| print s,
| results += s
|
| # Download the URL
| url = urllib.urlopen(searchURL % search)
| data = url.read()
| url.close()
|
| # Write the URL to a file for debugging
| fd = open('ebay %d.html' % i, 'w')
| fd.write(data)
| fd.close()
|
| # Search for the number of items found
| c = data.find('items found for')
| if c >= 0:
| start = data.rfind('<b>', 0, c) + 3
| stop = data.find('</b>', start + 1)
| cnt = data[start:stop]
| else:
| cnt = '0'
| s = "%s items found.\n" % cnt
| print s,
| results += s
|
| return results
|
|def Email(fromaddr, toaddr, subject, msg):
| ' Send email'
| msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % \
| (fromaddr, toaddr, subject, msg))
| server = smtplib.SMTP('your.smtp.server.here')
| server.set_debuglevel(1)
| server.sendmail(fromaddr, toaddr, msg)
| server.quit()
|
|main()


Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.