def start_project_on_all(request, projectname):
uniqueprojectname = request.user.username + '_' + projectname
try:
project = Project.objects.get(user=request.user, project_name=projectname)
except Project.DoesNotExist:
return HttpResponseNotFound('Nothing is here.')
workers = []
workers.append(settings.LINK_GENERATOR)
for worker in settings.SCRAPERS:
workers.append(worker)
if request.method == 'POST':
for worker in workers:
try:
r = requests.post('%s/schedule.json' % worker, data={'project': uniqueprojectname, 'spider': uniqueprojectname}, timeout=(3, None))
except:
pass
return HttpResponse('sent start signal')
views.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录