Difference between
modified post 24c by Anonymous on Thu 6th Jan 2011 18:48
original post fea41 by Anonymous on Thu 6th Jan 2011 16:46
Download diff
Show
old version |
new version |
both versions
| 1 | - | import urllib2 as url | |
| 1 | + | import urllib2 | |
| 2 | 2 | ||
| 3 | 3 | def getBetween(s, e, searched): | |
| 4 | 4 | sInd = searched.find(s) | |
| 5 | 5 | return searched[sInd + len(s):searched.find(e, sInd)] | |
| 6 | 6 | ||
| 7 | 7 | def get(url): | |
| 8 | 8 | isHards = [] | |
| 9 | 9 | isbns = [] | |
| 10 | 10 | done = False | |
| 11 | 11 | for pg in xrange(1, 5000): | |
| 12 | - | html = url.urlopen(url + '?PG=%d' % pg).read() | |
| 12 | + | html = urllib2.urlopen(url + '?PG=%d' % pg).read() | |
| 13 | 13 | eInd = 0 | |
| 14 | 14 | while True: | |
| 15 | 15 | sInd = html.find("<span class='regGray11px'>(", eInd) | |
| 16 | 16 | if sInd == -1: | |
| 17 | 17 | if eInd == 0: | |
| 18 | 18 | done = True | |
| 19 | 19 | break | |
| 20 | 20 | eInd = html.find("</span>\n", sInd) | |
| 21 | 21 | foo = html[sInd + len("<span class='regGray11px'>("):eInd] | |
| 22 | 22 | isHards.append('Hardback' in foo) | |
| 23 | 23 | isbns.append(getBetween('ISBN10: ', ';', foo)) | |
| 24 | 24 | if done: | |
| 25 | 25 | break | |
| 26 | - | return results | |
| 26 | + | return isHards, isbns | |
| 27 | 27 | ||
| 28 | 28 | print get('http://www.textbooks.com/Catalog/KMG/Geometry-for-K-12.php') | |
| 29 | 29 | ||
| 30 | 30 | ###### | |
| 31 | 31 | ||
| 32 | 32 | http://www.chartwellyorke.com/fathom/fathomdemos.html | |
| 33 | 33 | ||
| 34 | 34 | http://isbndb.com/ |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
fferen.kpaste.net RSS