Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kamujun committed Apr 7, 2017
2 parents c313651 + 600c6fc commit da704a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/data/make_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import json
import os

import requests
from bs4 import BeautifulSoup
BASE_DIR = os.path.join(os.path.dirname(__file__), '../../data/')


Expand All @@ -17,6 +19,13 @@ def list_labels():
yield item_id, labels


def get_likecount(url):
html = requests.get(url).text
soup = BeautifulSoup(html, 'html.parser')
likecount = soup.find(class_="js-likecount").text
return likecount


def add_annotations():
for item_id, labels in list_labels():
target_dir = 'processed/items'
Expand All @@ -35,6 +44,7 @@ def add_annotations():
}
for annotator_id, quality in enumerate(labels)
]
item['likes'] = get_likecount(item['url'])
wf.write(json.dumps(item, indent=4, ensure_ascii=False))


Expand Down

0 comments on commit da704a0

Please sign in to comment.