Diff for MashupKorea
FrontPage|FindPage|TitleIndex|RecentChanges|UserPreferences E D R S I M H RSS

Difference between r1.4 and the current

@@ -1,5 +1,4 @@
 
{{{#!vim python
{{{
# -*- coding: cp949 -*-

if __name__ == '__main__':
@@ -48,5 +47,4 @@
print r[0], '[ °¡°Ý:', r[2], ']', r[1]

}}}



# -*- coding: cp949 -*-

if __name__ == '__main__':
	daumUrl = "http://apis.daum.net/search/book?%s"
	naverUrl = "http://openapi.naver.com/search?%s"

	daumParams = {
	"apikey" : "9382530ef3abb0588bb463e07259644917e2dd45",
	"target" : "meta",
	}
	naverParams = {
	"key" : "6f4ad5dbec8f118d6869767b9fbcefe4",
	"target" : "book"
	}

	print '°Ë»öÇÒ Á¦¸ñÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä'
	title = raw_input()

	daumParams['q'] = title
	naverParams['query'] = title.decode('cp949').encode('utf-8')

	import urllib
	daumResult = urllib.urlopen(daumUrl % urllib.urlencode(daumParams)).read()
	naverResult = urllib.urlopen(naverUrl % urllib.urlencode(naverParams)).read()

	import BeautifulSoup
	daumBook = BeautifulSoup.BeautifulSoup(daumResult)
	naverBook = BeautifulSoup.BeautifulSoup(naverResult)

	allResult = [] # ( ['Daum'/'Naver'], title, price ) ...

	for it in daumBook.findAll('item'):
		allResult.append( ('Daum', 
			it.find('title').contents[0].encode('cp949'), 
			it.find('sale_price').contents[0].encode('cp949'))
		)

	for it in naverBook.findAll('item'):
		allResult.append( ('Naver', 
			it.find('title').contents[0].encode('cp949'), 
			it.find('price').contents[0].encode('cp949'))
		)

	allResult.sort(key=lambda d: int(d[2])) # ,reverse=True) 
	for r in allResult:
		print r[0], '[ °¡°Ý:', r[2], ']', r[1]
		

ShowPage|FindPage|DeletePage|LikePages| Valid XHTML 1.0! Valid CSS! powered by MoniWiki