thejagstudio commited on
Commit
1c083b2
1 Parent(s): 387c1bb

session gone

Browse files
Files changed (1) hide show
  1. amazon/views.py +9 -6
amazon/views.py CHANGED
@@ -7,6 +7,8 @@ import requests
7
  from bs4 import BeautifulSoup
8
  # Create your views here.
9
 
 
 
10
 
11
  def sessionIdGenrator():
12
  conn = http.client.HTTPSConnection("www.amazon.in")
@@ -165,20 +167,21 @@ def getProductDetail(request):
165
 
166
  @api_view(['GET'])
167
  def searchQuery(request):
 
168
  query = request.GET.get('query')
169
  if not ('ue_sid' in request.session and 'ue_mid' in request.session):
170
  ue_sid, ue_mid = sessionIdGenrator()
171
- request.session['ue_sid'] = ue_sid
172
- request.session['ue_mid'] = ue_mid
173
  else:
174
- ue_sid = request.session['ue_sid']
175
- ue_mid = request.session['ue_mid']
176
  try:
177
  tempData = searchAPI(ue_sid, ue_mid, query)
178
  except:
179
  ue_sid, ue_mid = sessionIdGenrator()
180
- request.session['ue_sid'] = ue_sid
181
- request.session['ue_mid'] = ue_mid
182
  tempData = searchAPI(ue_sid, ue_mid, query)
183
  values = []
184
  for i in tempData["suggestions"]:
 
7
  from bs4 import BeautifulSoup
8
  # Create your views here.
9
 
10
+ ue_sid_global = ""
11
+ ue_mid_global = ""
12
 
13
  def sessionIdGenrator():
14
  conn = http.client.HTTPSConnection("www.amazon.in")
 
167
 
168
  @api_view(['GET'])
169
  def searchQuery(request):
170
+ global ue_sid_global,ue_mid_global
171
  query = request.GET.get('query')
172
  if not ('ue_sid' in request.session and 'ue_mid' in request.session):
173
  ue_sid, ue_mid = sessionIdGenrator()
174
+ ue_sid_global = ue_sid
175
+ ue_mid_global = ue_mid
176
  else:
177
+ ue_sid = ue_sid_global
178
+ ue_mid = ue_mid_global
179
  try:
180
  tempData = searchAPI(ue_sid, ue_mid, query)
181
  except:
182
  ue_sid, ue_mid = sessionIdGenrator()
183
+ ue_sid_global = ue_sid
184
+ ue_mid_global = ue_mid
185
  tempData = searchAPI(ue_sid, ue_mid, query)
186
  values = []
187
  for i in tempData["suggestions"]: