scrapp post

This commit is contained in:
Maciej Ścigacz 2023-05-30 00:47:35 +02:00
parent 778366b30c
commit 9e48b92d3e
2 changed files with 9 additions and 5 deletions

View File

@ -39,8 +39,12 @@ def count_predictions(predictions):
return all return all
def scrapp_comments(url): def scrapp_comments(url):
result = [] comments= []
all = {}
for post in get_posts(post_urls=[url], options={"allow_extra_requests": False, "comments":True, "extra_info":True}): for post in get_posts(post_urls=[url], options={"allow_extra_requests": False, "comments":True, "extra_info":True}):
text_post = post['text']
for comment in post['comments_full']: for comment in post['comments_full']:
result.append(comment['comment_text']) comments.append(comment['comment_text'])
return result all['post'] = text_post
all['comments'] = comments
return all

View File

@ -24,5 +24,5 @@ def get_data():
@sentiment_service.route("/scrapp_comments", methods=['POST']) @sentiment_service.route("/scrapp_comments", methods=['POST'])
def scrapp(): def scrapp():
url = request.get_json() url = request.get_json()
comments = scrapp_comments(url['link']) result = scrapp_comments(url['link'])
return jsonify({'sentences':comments}) return result