@qoderman/

auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuugh

Python

No description

fork
loading
Files
  • main.py
  • nltk_data
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from textblob import TextBlob
import requests
import sys
import nltk

nltk.download('punkt')
page = requests.get("https://www.instagram.com/realdonaldtrump/?hl=en")

message = str(page.content)
score = 0
count = 0
while '"text":"' in message and '"}}]}' in message:
  index1 = message.index('"text":"') + 8
  index2 = message.index('"}}]}')
  s = message[index1:index2]
  text = TextBlob(s)
  print(s)
  print(text.sentiment.polarity)
  print()

  score += text.sentiment.polarity
  count += 1
  message = message[index2 + 5:]

print (score/count)