Esempio n. 1
0
def run(TWITTER_ID="askaniyagavril6",
        TWITTER_PASS="******",
        TWITTER_EMAIL="*****@*****.**",
        GMAIL_ADRESS="*****@*****.**",
        GMAIL_PASS="******",
        PHONE_NUMBER="(830) 308-7334",
        APP_IP='36.55.241.31'):

    tw = Twitter(twitter_id=TWITTER_ID,
                 twitter_pass=TWITTER_PASS,
                 twitter_email=TWITTER_EMAIL)
    tw.setLangage()
    tw_driver = tw.getDriver()
    try:
        tw.setPhone(phone_number=PHONE_NUMBER)
    except AlreadyAddedPhoneNumber:
        sl = SocialLogin(driver=tw_driver, app_ip=APP_IP)
        sl.twitterLogin()
        tw.close()
        raise AlreadyAddedPhoneNumber()
    gm = Gmail(gmail_adress=GMAIL_ADRESS, gmail_pass=GMAIL_PASS)
    pin_code = gm.getPinCode()
    sleep(5)
    tw.setPINKey(pin_code=pin_code)
    if (tw.checkMobile() == False):
        tw.close()
        gm.close()
        raise PhoneNumberInvalidError()
    driver = tw.getDriver()
    sl = SocialLogin(driver=driver, app_ip=APP_IP)
    sl.twitterLogin()
    tw.close()
    gm.close()
Esempio n. 2
0
 def extract(self, user, consumer_key, consumer_secret, access_token,
             access_token_secret, test):
     self.logger.init_tweet_log(user)
     self.logger.log_system("Connecting to Twitter...")
     twitter = Twitter(consumer_key, consumer_secret, access_token,
                       access_token_secret, test)
     twitter.auth()
     self.logger.log_system("Connected. Extracting user timeline...")
     timeline = twitter.timeline(user)
     count = 0
     for tweet in timeline:
         if "text" in tweet:
             count = count + 1
             self.logger.log_system("Tweet logged: #:%d | ID:%s" %
                                    (count, tweet["id"]))
             # print json.dumps(tweet, ensure_ascii=False).encode('utf8')
             self.logger.log_tweet(tweet)
             if count >= 3180 and test:
                 self.logger.log_system(
                     "Approaching 3200 tweet limit for open API; closing connection"
                 )
                 twitter.close()
                 break
         elif "message" in tweet:
             self.logger.log_system("Message %s" % tweet[message])
             break
     self.logger.close_tweet_log()
     return self.logger.get_output_file()
Esempio n. 3
0
def run(TWITTER_ID="askaniyagavril6",
        TWITTER_PASS="******",
        TWITTER_EMAIL="*****@*****.**",
        GMAIL_ADRESS="*****@*****.**",
        GMAIL_PASS="******",
        PHONE_NUMBER="(830) 308-7334"):

    tw = Twitter(twitter_id=TWITTER_ID,
                 twitter_pass=TWITTER_PASS,
                 twitter_email=TWITTER_EMAIL)
    tw.setLangage()
    tw.setPhone(phone_number=PHONE_NUMBER)
    gm = Gmail(gmail_adress=GMAIL_ADRESS, gmail_pass=GMAIL_PASS)
    pin_code = gm.getPinCode()
    sleep(5)
    tw.setPINKey(pin_code=pin_code)

    driver = tw.getDriver()
    sl = SocialLogin(driver=driver)
    sl.twitterLogin()
    tw.close()
    gm.close()
Esempio n. 4
0
 def loginTwitter(self,loginList):
     self.twitterID = Twitter.Twitter(str(loginList[0]),str(loginList[1]))
     self.twitterID.signIn()
Esempio n. 5
0
import WeatherApiUi as wau
import TwiText
import Twitter
import WeatherDataExtractor as tc
import APIgetDataException as apie
from time import sleep
import WeatherData as wd

seto = ('35.1815', '137.1087')
toyota = ('35.08', '137.15')
owariasahi = ('35.21', '137.03')
miyoshi = ('35.13', '137.05')
nissin = ('35.17', '136.96')

twitter = Twitter.Twitter()
twitext = TwiText.TwiText()
weatherApi = wau.WeatherApiUi()
extractor = tc.WeatherDataExtractor()


def beSureToDo(city):
    while (True):
        try:
            data = weatherApi.getDataLatLon(city[0], city[1], 1)
            weatherData = extractor.getAllData(data)
            twitter.twitte(twitext.Build(weatherData))
        except apie.APIgetDataException:
            sleep(60)
            continue
        break
Esempio n. 6
0
 def test_13_FollowUpdates_WithArgs_Fail_With_Arg(self):
     self.assertRaises(Exception,
                       Twitter.Twitter('TestStr', 'TestStr').FollowUpdates,
                       'TestStr0')
Esempio n. 7
0
 def test_12_FollowUpdates_WithoutArgs_Pass_With_Only_Valid_Arguments(self):
     Twitter.Twitter('TestStr', 'TestStr').FollowUpdates()
Esempio n. 8
0
 def test_11_signIn_WithArgs_Fail_With_Arg(self):
     self.assertRaises(Exception,
                       Twitter.Twitter('TestStr', 'TestStr').signIn,
                       'TestStr0')
Esempio n. 9
0
 def test_10_signIn_WithoutArgs_Pass_With_Only_Valid_Arguments(self):
     Twitter.Twitter('TestStr', 'TestStr').signIn()
Esempio n. 10
0
 def test_8_getStatus_WithoutArgs_Pass_With_Only_Valid_Arguments(self):
     Twitter.Twitter('TestStr', 'TestStr').getStatus()
Esempio n. 11
0
 def test_7_printcurrStatus_WithArgs_Fail_With_Arg(self):
     self.assertRaises(
         Exception,
         Twitter.Twitter('TestStr', 'TestStr').printcurrStatus, 'TestStr0')
Esempio n. 12
0
 def test_6_printcurrStatus_WithoutArgs_Pass_With_Only_Valid_Arguments(
         self):
     Twitter.Twitter('TestStr', 'TestStr').printcurrStatus()
Esempio n. 13
0
 def test_2_Twitter_WithArgs_Pass_With_Only_Valid_Arguments(self):
     Twitter.Twitter('TestStr', 'TestStr')
Esempio n. 14
0
# -*- coding: utf-8 -*-
import sys
sys.path.insert(0, '/Users/takashi/Projects/twitter_auto_login')
from Twitter import *
from Excel import *
result = getSheet(fileName="./uploads/twitter.xlsx", sheetName="Accounts")

for row in result:
    print(result[0])
    if row[0] == u'Login':
        row.append('Login-status')
        continue
    twitter_id = row[0]
    twitter_pass = row[1]
    twitter_email = row[2]
    tw = Twitter(twitter_id=twitter_id,
                 twitter_pass=twitter_pass,
                 twitter_email=twitter_email)
    print(tw.getLoginStatus())
    if tw.getLoginStatus() == True:
        row.append("success")
    else:
        row.append("error")
    tw.close()
Esempio n. 15
0
import Twitter

mytwit = Twitter.Twitter("usrn", "PASS")
mytwit.signIn()
mytwit.setStatus("SAP")
mytwit.printcurrStatus()
mytwit.setStatus("PAS")
mytwit.printcurrStatus()
Esempio n. 16
0
 def setUp(self):
     self.twitter = Twitter()
Esempio n. 17
0
# Developed and modified by Ye Liang at 11:11 June,3 2017
# All rights reserved
from ExtraTools import write_To_Csv, sleep_Module
import Twitter
import Sqlite
import Parser
import Cluster
CONST_DAYS_INCLUDED = 1


if __name__ == '__main__':
    #----------initialize the modules and settings---------------------begin
    db = Sqlite.Sqlite("database.db")
    parserModule = Parser.Parser()
    clusterModule = Cluster.Cluster()
    twitterModule = Twitter.Twitter(db, parserModule)
    #----------initialize the modules and settings---------------------end

    runSequence = True
    while(runSequence):
        # update all tweets into the database within CONST_DAYS_INCLUDED day
        twitterModule.update_All()
        # get all updated tweets within CONST_DAYS_INCLUDED day
        news24H = db.get_stored_news(CONST_DAYS_INCLUDED)
        # cluster, and find the best news
        sortedNews, labels, sortedScores = clusterModule.cluster_AP(news24H)
        # write to csv file
        write_To_Csv(sortedNews, sortedScores, 'Sorted_Best_Tweets (one for each cluster).csv')
        # sleeping procedure
        runSequence = sleep_Module(600)
    db.close()
Esempio n. 18
0
 def test_9_getStatus_WithArgs_Fail_With_Arg(self):
     self.assertRaises(Exception,
                       Twitter.Twitter('TestStr', 'TestStr').getStatus,
                       'TestStr0')