Skip to content

Instantly share code, notes, and snippets.

@yevgnenll
Created March 22, 2016 15:23
Show Gist options
  • Save yevgnenll/43cc78916d6060174b42 to your computer and use it in GitHub Desktop.
Save yevgnenll/43cc78916d6060174b42 to your computer and use it in GitHub Desktop.
from django.db import models
from socials.utils import NaverCrawling
class Keyword(models.Model):
name = models.CharField(
max_length=30,
unique=True,
)
created_at = models.DateTimeField(
auto_now_add=True,
)
updated_at = models.DateTimeField(
auto_now=True,
)
def __str__(self):
return self.name
def crawl_naver(self):
print("system come in model!!")
PROVIDER = 'naver'
crawl = NaverCrawling()
result = crawl.naver_blog_page10(self.name)
links = result.get('link')
titles = result.get('title')
for idx, link in enumerate(links):
social_post, created = self.social_post_set.get_or_create(
url = link,
)
if created:
social_post.provider = PROVIDER
social_post.title = titles[idx]
social_post.save()
def crawl_daum(self):
pass
def crawl_nate(self):
pass
def crawl_all(self):
self.crawl_naver()
self.crawl_duam()
self.crawl_nate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment