usernameOsint.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:DataSploit 作者: zanyarjamal 项目源码 文件源码
def twitterdetails(username):
    auth = tweepy.OAuthHandler(cfg.twitter_consumer_key, cfg.twitter_consumer_secret)
    auth.set_access_token(cfg.twitter_access_token, cfg.twiter_access_token_secret)

    #preparing auth
    api = tweepy.API(auth)


    f = open("temptweets.txt","w+")
    #writing tweets to temp file- last 1000
    for tweet in tweepy.Cursor(api.user_timeline, id=username).items(1000):
        f.write(tweet.text.encode("utf-8"))
        f.write("\n")



    #extracting hashtags
    f = open('temptweets.txt', 'r')
    q=f.read()
    strings = re.findall(r'(?:\#+[\w_]+[\w\'_\-]*[\w_]+)', q)   #Regex(s) Source: https://marcobonzanini.com/2015/03/09/mining-twitter-data-with-python-part-2/
    #extracting users
    tusers = re.findall(r'(?:@[\w_]+)', q)
    f.close()

    hashlist=[]
    userlist=[]
    for item in strings:
        item=item.strip( '#' )
        item=item.lower()
        hashlist.append(item)

    hashlist=hashlist[:10]
    for itm in tusers:
        itm=itm.strip( '@' )
        itm=itm.lower()
        userlist.append(itm)

    userlist=userlist[:10]

    return hashlist,userlist
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号