示例#1
0
def twitter(request):
    context = {}
    if request.method == "POST":
        resp_Arr = []
        user_input = request.POST.get("usernames")
        user_input = user_input.strip()
        if user_input != "":
            if user_input[:1] == "#":
                twitter_resp_data = TwitterHashTagProcess(user_input)
                context["data1"] = json.loads(twitter_resp_data)
                context["hashtag"] = user_input
                # print(context)
                return render(request,"twitter.html",context)
            else:
                user_List = user_input.split(",")
                for user_name in user_List:
                    user_name = user_name.strip()
                    if user_name != "":
                        # print(user_name)
                        try:
                            twitter_resp_data = TwitterUserNameProcess(user_name)
                            user_profile = ts.Profile(user_name).to_dict()
                            resp_Arr.append({
                                "username":user_name,
                                "data":json.loads(twitter_resp_data),
                                "user_profile":user_profile
                            })
                        except Exception as e:
                            context["error"] = "{}".format(e)
                context["data"] = resp_Arr

        else:
            context["error"] = "Please type a twitter username in the input field."

    return render(request,"twitter.html",context)
示例#2
0
def suspect(request):
    context = {}
    context["data"] = []
    suspect_username = SuspectList.objects.filter(name="raghav")[0].suspect_list
    for user in suspect_username:
        resp = ts.Profile(user).to_dict()
        context["data"].append(resp)
    # print(context)
    return render(request,"suspect.html",context)
def suspect(request):
    context = {}
    context["data"] = []
    suspect_username = SuspectList.objects.filter(
        name="raghav")[0].suspect_list
    for user in suspect_username:
        resp = ts.Profile(user).to_dict()
        context["data"].append(resp)
    # print(context)
    return render(request, "suspect.html", context)


#   "/api/twitter/raghav/suspect-list"
#   "for every user there should be an suspect list"
示例#4
0
def get_user_profile(username):
    scrape_profile = twitter_scraper.Profile(username)

    profile = Profile()
    profile.name = scrape_profile.name
    profile.username = scrape_profile.username
    profile.birthday = scrape_profile.birthday
    profile.bio = scrape_profile.biography
    profile.website = scrape_profile.website
    profile.profile_photo = scrape_profile.profile_photo
    profile.likes_count = scrape_profile.likes_count
    profile.tweets_count = scrape_profile.tweets_count
    profile.followers_count = scrape_profile.followers_count
    profile.following_count = scrape_profile.following_count

    return profile.to_dict()
示例#5
0
def get_profile(request,username):
  context = ts.Profile(username).to_dict()
  return JsonResponse(context,safe=False)
示例#6
0
pp = pprint.PrettyPrinter(indent=4)

###

count = 0

for tweet in ts.get_tweets("ConanOBrien", pages=10000):
    count += 1
    # pp.pprint(tweet)

print(count)

###

profile = ts.Profile("ConanOBrien")

profile = profile.to_dict()

pp.pprint(profile)

c = twint.Config()
c.Username = "******"
c.Limit = None
c.Store_object = True
c.Hide_output = True

twint.run.Search(c)
tweets = twint.output.tweets_list

print(len(tweets))
示例#7
0
def get_profile(profile_name):
  "Gives you details of the profile provided"
  return ts.Profile(profile_name).to_dict()