Amazon
parent
3f7fcb35ad
commit
cc45894155
|
@ -25,6 +25,7 @@ versiontools
|
||||||
Werkzeug
|
Werkzeug
|
||||||
|
|
||||||
git+git://github.com/dlo/bottlenose.git
|
git+git://github.com/dlo/bottlenose.git
|
||||||
|
git+git://github.com/yoavaviram/python-amazon-simple-product-api.git
|
||||||
git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
|
git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
|
||||||
hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registration
|
hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registration
|
||||||
git+https://github.com/toastdriven/django-tastypie.git#egg=django-tastypie
|
git+https://github.com/toastdriven/django-tastypie.git#egg=django-tastypie
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
{{ result|safe }}
|
|
28
views.py
28
views.py
|
@ -3,23 +3,33 @@ from django.shortcuts import render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from snipts.utils import get_lexers_list
|
from snipts.utils import get_lexers_list
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
from amazon.api import AmazonAPI
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
|
from django.template.defaultfilters import striptags
|
||||||
import bottlenose
|
|
||||||
|
|
||||||
|
|
||||||
|
@ajax_request
|
||||||
def amazon_search(request):
|
def amazon_search(request):
|
||||||
|
|
||||||
result = ''
|
products = []
|
||||||
if request.GET.get('q'):
|
if request.GET.get('q'):
|
||||||
|
amazon = AmazonAPI('AKIAJJRRQPTSPKB7GYOA', 'DIYz2g5vPjcWE4/YI7wEuUVAskwJxs2llFvGyI1a', 'snipt-20')
|
||||||
|
products = amazon.search_n(5, Keywords=request.GET.get('q'), SearchIndex='Books')
|
||||||
|
|
||||||
amazon = bottlenose.Amazon('AKIAJJRRQPTSPKB7GYOA', 'DIYz2g5vPjcWE4/YI7wEuUVAskwJxs2llFvGyI1a', 'snipt-20')
|
result = []
|
||||||
result = amazon.ItemSearch(Keywords=request.GET.get('q'), SearchIndex='All')
|
for product in products:
|
||||||
|
result.append({
|
||||||
|
'image': product.small_image_url,
|
||||||
|
'price': product.list_price,
|
||||||
|
'review': striptags(product.editorial_review),
|
||||||
|
'reviews': product.reviews,
|
||||||
|
'title': product.title,
|
||||||
|
'url': product.offer_url,
|
||||||
|
})
|
||||||
|
|
||||||
return render_to_response('amazon.xml',
|
return {
|
||||||
{'result': result},
|
'result': result
|
||||||
context_instance=RequestContext(request),
|
}
|
||||||
mimetype='application/xml')
|
|
||||||
|
|
||||||
@ajax_request
|
@ajax_request
|
||||||
def lexers(request):
|
def lexers(request):
|
||||||
|
|
Loading…
Reference in New Issue