script to search ebay?

L

Lance Hoffmeyer

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
 
K

Kamilche

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('(e-mail address removed)',
| '(e-mail address removed)',
| '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.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()
 
L

Lance Hoffmeyer

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top