Since my request for the API was rejected, I commenced using python parsing libraries.
Callerpy emulates the process one would encounter if using a web-browser.
The procedure
callerpy.py
:::python
......defRun():current_date=datetime.datetime.now()printclr.YELproceed=raw_input("shall I proceed? Y/N ")printclr.ENDCifproceedin('yes','y','Y','YES'):html=open('twill_output','r')a=html.read()bs=BeautifulSoup(a)if'<p class="sr-name">'ina:print'Result Ready\n'fornuminbs.find_all('p',{"class":"sr-name"}):#printnump=re.split(r'<.*?>',str(num))foriinp:printihist=open('history.log','a')hist.write('On %s ----- [[%s]] \n'%(current_date,p))hist.close()elif'http://www.truecaller.com/social_auth/?p=social_auth_index'ina:printclr.REDprint'Something went wrong'printclr.ENDChist=open('history.log','a')hist.write('On %s ----- %s \n'%(current_date,'No match was found'))hist.close()html.close()elifproceedin('no','n','N','NO'):KeyboardInterruptprint'Goodbye'if__name__=="__main__":iflen(sys.argv)>1:callerpyFunc=sys.argv[1]ifcallerpyFunc=='-hist':history()ifcallerpyFunc=='-ph':print'Please wait...'auth.AUTH()Run()
When the script runs, it will call auth.AUTH()
auth.py
:::python
CallerUrl="http://www.truecaller.com/"#Thefirstpartofthefunctionwillgettwitter'soauth_token.defAUTH():dele=open('twill_output','r+')#neededtoinsurethattwill_outputstayscleandele.truncate()#connecttotruecallerandretrievetwitter'soauth_tokenhashusingre.splitprintclr.MOVprint'\nPlease wait while I get the Token\n'printclr.ENDCAuthURL="social_auth/?p=social_auth_index"twitterAuthURL="&action=login&type=twitter"httpIt=CallerUrl+AuthURL+twitterAuthURLhttp=httplib2.Http()status,response=http.request(httpIt)bs=BeautifulSoup(response)fornuminbs.find_all(re.compile("a")):ifnum.has_attr('href')==True:iflen(num['href'])>50:#Constantlinksarelessthan48#printnum.get('href')+clr.ENDC+'\n'print'Twitter token hash:\n'+clr.YELa=re.split('=',num.get('href'))fortokenina:iflen(token)>38:printtokenprintclr.ENDC#connecttotwitterandsubmitthetokenprintclr.MOVprint'\nPlease wait while I get the Token\n'printclr.ENDCtwitter_URL='https://api.twitter.com/oauth/authorize?oauth_token='twitter_authURL=twitter_URL+tokenprint'Twitter oauth_token link:\n'+clr.YELprinttwitter_authURLprintclr.ENDCurlRedirect.truecaller_from_twitter(url=twitter_authURL)return
The current mean of logging in into truecaller is by twitter.
auth.py will connect to truecaller and follow the authentication process to twitter. It will then retrieve oauth_token and send it to urlRedirect.py
urlRedirect.py
:::python
deftruecaller_from_twitter(url):time.sleep(0.5)try:op=open('twill_output','w+')twill.set_output(op)#redirect_output('twill_output')#Willonlywriteafterscripthasfinishedduetomissingclose()incommands.pyexcept:print'Could not write to file'go(url)showforms()#Fortestingformclear('1')fv("1","session[username_or_email]","USERNAME")#changeusername/passwordtostringforhardcodedcredsfv("1","session[password]","PASSWORD")fv("1","None","1")print'\n'showforms()#Fortestingsubmit('6')save_cookies('cookie_session_twitter')time.sleep(1)number=raw_input('Please enter number: ')go('http://www.truecaller.com')showforms()formclear('1')fv('1','q',str(number))submit('3')showforms()info()show()op.close()
urlRedirect.py will submit your credentials to twitter and authorise truecaller. It will then save the cookie as cookie_session_twitter and submit the truecaller form.
NOTE: save__cookies() and cookie_session_twitter are part of a previous testing version. Currently they have no use.
update 30/06/2013
UPDATE An early version is available for Penbang 0.0.3
You could also download it penbang-scripts
You will need to change the paths to get it working correctly.
Callerpy is a truecaller name retriever.
Since my request for the API was rejected, I commenced using python parsing libraries.
Callerpy emulates the process one would encounter if using a web-browser.
The procedure
callerpy.py
:::python
When the script runs, it will call auth.AUTH()
auth.py
:::python
The current mean of logging in into truecaller is by twitter.
auth.py will connect to truecaller and follow the authentication process to twitter. It will then retrieve oauth_token and send it to urlRedirect.py
urlRedirect.py
:::python
urlRedirect.py will submit your credentials to twitter and authorise truecaller. It will then save the cookie as cookie_session_twitter and submit the truecaller form.
NOTE:
save__cookies() and cookie_session_twitter are part of a previous testing version. Currently they have no use.
Example of cookie_session_twitter
:::cookie
All of your "lookups" will be stored in history.log using the following format
:::history.log
Last edit: Logic-Gate 2013-06-29