コード例 #1
0
ファイル: views.py プロジェクト: asatia07/albertatrades
def search(request):
    query = request.GET.get('query',"").strip()
    location = request.GET.get('location',"").strip()
    jobs = []
    if query and (not query.isspace()):
        if not location:
            location = config.INDEED_JOBS_DEFAULT_LOCATION
        create_search_history(request, query, location)
        params = {'query': query, 'location': location}
        response = indeed_api.fetch_jobs(params)
        if response["error"]:
            print response["message"]
        else:
            for row in response["trade_info"]:
                jobs.append(
                                {
                                    "title": row["jobtitle"],
                                    "company": row["company"],
                                    "city": row["city"],
                                    "state": row["state"],
                                    "country": row["country"],
                                    "date": row["date"],
                                    "url": row["url"],
                                    "formattedLocationFull": row["formattedLocationFull"],
                                    "formattedRelativeTime": row["formattedRelativeTime"],
                                }
                            )
    context = {"jobs":jobs, "query":query, "location":location}
    return render(request, 'indeed/search.html', context=context)
コード例 #2
0
ファイル: cron.py プロジェクト: asatia07/albertatrades
 def do(self):
     trades = models.Trade.objects.all()
     for trade in trades:
         params = {'query': trade.query}
         response = indeed_api.fetch_jobs(params, job_count=True)
         if response["error"]:
             print response["message"]
             logger.error(response["message"])
         else:
             trade_info = response["trade_info"]
             job_counts = trade_info["totalResults"]
             if trade.query:
                 models.Trade.objects.filter(query=trade.query).update(job_counts=job_counts)
                 msg = "Job count updated for %s trade" %(trade.query)
                 logger.info(msg)