script to search ebay?

Lance Hoffmeyer lance-news at augustmail.com
Wed Jan 26 03:05:17 EST 2005


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('me at somewhere.com',
> |          'you at 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()




More information about the Python-list mailing list