Skip to content

Instantly share code, notes, and snippets.

from celery import Task
from .naver import SocialsCrawlNaverTask
from .daum import SocialsCrawlDaum
from .nate import SocialsCrawlNate
class SocialsCrawlAllTask(Task):
def run(self, keyword_id):
from celery import Task
from socials.models import Keyword
class SocialsCrawlNaverTask(Task):
def run(self, keyword_id):
keyword = Keyword.objects.get(pk=keyword_id)
keyword.crawl_naver()
from django.db import models
from socials.utils import NaverCrawling
class Keyword(models.Model):
name = models.CharField(
max_length=30,
unique=True,
)
from django.db.models.signals import post_save
from django.dispatch import receiver
from socials.models import Keyword
from socials.tasks import SocialsCrawlAllTask
@receiver(post_save, sender=Keyword)
def post_save_keyword(sender, instance, created, **kwargs):
import requests
from bs4 import BeautifulSoup
class NaverCrawling:
def __init__(self):
self.naver_blog = "https://search.naver.com/search.naver?where=post&ie=utf8&query={query}&start={start}"
def naver_blog_page(self, search_keyword, page):
-r requirements/production.txt
from django.db import models
from socials.utils import NaverCrawling
class Keyword(models.Model):
name = models.CharField(
max_length=30,
unique=True,
)
from django.db import models
class Keyword(models.Model):
name = models.CharField(
max_length=20,
)
created_at = models.DateTimeField(
from django.contrib import admin
from announce.models import SMS, Slack, Email
@admin.register(SMS)
@admin.register(Slack)
@admin.register(Email)
class AnnouncesAdminModel(admin.ModelAdmin):
list_display = admin.ModelAdmin.list_display + (
from posts.models import Post
from rest_framework import serializers
class PostDetailSerializer(serializers.HyperlinkedModelSerializer):
username = serializers.CharField(source="user.username")
class Meta:
model = Post