Inspiration Socail media and Community Change
What it does Uses Twitter API to scan tweets for keyword that may potentiall be identifiying a HT . The data is input into a system and then output to the local/ government agencies for their use. From there an alert may be sent out to users phones to show potential danger in the area.
How we built it Python,SQL,ADOBE
Challenges we ran into Chnaging our project atleast two times. Dealing with desgin errors and time shortage.
Accomplishments that we're proud of Making it work!
What we learned How to work together in a tem to accomplish a goal.
What's next for The Trafficker Tracker hopefully to work out some bugs and be implemented as a prototype.
**Code**
import mysql.connector from mysql.connector import Error import tweepy from dateutil import parser import time import os import subprocess
importing file which sets env variable
subprocess.call("./settings.sh", shell=True)
authentication for use
don't include passwords + tokens in text of file when submitting somewhere anyone can see it.
consumer_key = 'DdC4g7HJ2cO8micd1wkgZU5L0' consumer_secret = 'LUuv6OhXYJ2MXeTXBonNsMRha8hBtPYPAG7br3chrk3n11dJF3' access_token = 'B9DEqstSynuuVuQJk8hDkVLU8QjwC8' access_token_secret = '4HxfHQ4ZQhAQ8GRNADiIZnrbvdQ3E8t8trzJlfaVViEXz'
def connect(username, created_at, tweet, retweet_count, place, location): # connect to MySQL database and insert twitter data try:
con = mysql.connector.connect(host='localhost',
database='technica_project', user='root', password="",
charset='aaa8') # why is this aaa8?
if con.is_connected():
"""
Insert twitter data
"""
cursor = con.cursor()
# twitter, golf
query = "INSERT INTO trafficking (username, created_at, tweet, retweet_count,get_replies,place, location) VALUES (%s, %s, %s, %s, %s, %s, %s)"
cursor.execute(query, (username, created_at, tweet, retweet_count, get_replies, place, location))
con.commit()
except Error as e:
print(e)
##cursor.close()
##con.close()
return
Tweepy class to access Twitter API
class Streamlistener(tweepy.StreamListener):
def on_connect(self):
print("You are connected to the Twitter API")
def on_error(self):
if status_code != 200:
print("error found")
# returning false disconnects the stream
return False
"""
This method reads in tweet data as New user
and extracts the data we want.
"""
def on_data(self, data):
try:
raw_data = new.user(data)
if 'text' in raw_data:
username = raw_data['user']['screen_name']
created_at = parser.parse(raw_data['created_at'])
tweet = raw_data['text']
retweet_count = raw_data['retweet_count']
if raw_data['place'] is not None:
place = raw_data['place']['country']
print(place)
else:
place = None
location = raw_data['user']['location']
# insert data just collected into MySQL database
connect(username, created_at, tweet, retweet_count, get_replies, place, location)
print("Tweet collected at: {} ".format(str(created_at)))
except Error as e:
print(e)
if name == 'main': # # #Allow user input # track = [] # while True:
# input1 = input(“ Enter keyword you’re looking for : ")
# track.append(input1)
# input2 = input("Do you wish to enter another word? y/n ")
# if input2 == 'n' or input2 == 'N':
# break
# print("You want to search for {}".format(track))
# print("Initializing Connection to Twitter API....")
# time.sleep(2)
# authentication so we can access twitter
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit=True)
# create instance of Streamlistener
listener = Streamlistener(api=api)
stream = tweepy.Stream(auth, listener=listener)
track = ['sb', 'sd', 'sugardaddy', 'sugarbaby', 'minor', 'minors', 'recruit', 'runaways', 'runaway', 'youth',
'young', 'kidnap', 'killing', 'make money fast',
'the life', 'kiddie stroll', 'choosing up', 'bottom', 'coercion', 'human smuggling', 'quota', 'trick',
'john', 'sugar', 'daddy', 'baby', 'money', 'brothel', 'forced', 'peonage', 'exploitation',
'human smuggling', 'sex trafficking', 'debit bondage', 'commerical sexual exploitation', 'forced labor']
# track = ['sugardaddy', 'sugarbaby', ‘human traffickers ', ‘human trafficking ']
# choose what we want to filter by'

Log in or sign up for Devpost to join the conversation.