urllib2 import re @csrf_exempt def find(request): try: service = build("customsearch","v1",\ developerKey="AIzaSyDBrtHVzXjrvKus_qGpPbTm9rJppIhjxvM") res = service.cse().list(q=request.POST['key'],\ cx='004982958264606934300:2o52rkqdfaw').execute() page = urllib2.urlopen(res['items'][0]['link']) soup = BeautifulSoup(page).body except: return HttpResponse("error") else: return HttpResponse(soup) search3/views.py