twintproject / twint

An advanced Twitter scraping & OSINT tool written in Python that doesn't use Twitter's API, allowing you to scrape a user's followers, following, Tweets and more while evading most API limitations.
MIT License
15.66k stars 2.72k forks source link

Cannot format user lookup #562

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi guys,

Hope you are all well !

I cannot format the output while doing a lookup on a user.

Any ideas about how to solve this problem ?

import twint

account_id = "953155617098694656"

def getUsername(target):
  c = twint.Config()
  c.User_id = target
  c.Store_object = True
  c.Hide_output = False
  c.Debug = True
  c.Format = "ID {id} | Username {username}"
  twint.run.Lookup(c)
  return twint.output.users_list

if __name__ == "__main__":
  getUsername(account_id)

error triggered

CRITICAL:root:twint.get:User:replace() argument 2 must be str, not None

Best, X.

erlendstromsvik commented 4 years ago

You have verified that you get the user details without the format? I'm asking because I just discovered that I'm only getting Username - 'NoneType' object is not subscriptable on all User searches.

ghost commented 4 years ago

if I comment c.Format, I have

953155617098694656 | MO7EP | @MO7EPMASRY | Private: 0 | Verified: 0 | Bio:  | Location:  | Url: None | Joined: 15 Jan 2018 10:43 PM | Tweets: 107 | Following: 1986 | Followers: 56 | Likes: 2 | Media: 2 | Avatar: https://abs.twimg.com/sticky/default_profile_images/default_profile_400x400.png

so there is a problem in formatting the outpout

pielco11 commented 4 years ago

immagine

ghost commented 4 years ago

works for that but not for csv output... ^^

pielco11 commented 4 years ago

@x0rzkov for CSV/JSON output you have to set c.Custom['user']

immagine

ghost commented 4 years ago

it works, thanks a lot !