views.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Distributed-Multi-User-Scrapy-System-with-a-Web-UI 作者: aaldaber 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号