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.81k stars 2.73k forks source link

Error on running example code ('NoneType' object is not subscriptable) #296

Closed filletofish closed 5 years ago

filletofish commented 5 years ago

Command Ran

Just an example from README.md

import twint

# Configure
c = twint.Config()
c.Username = "now"
c.Search = "pineapple"
c.Format = "Tweet id: {id} | Tweet: {tweet}"

# Run
twint.run.Search(c)

Description of Issue

running python3 example.py leads to following errors:

'NoneType' object is not subscriptable [x] get.User
Traceback (most recent call last):
  File "example.py", line 10, in <module>
    twint.run.Search(c)
  File "/Users/filletofish/Dev/DataMiningEcon/src/twint/twint/run.py", line 215, in Search
    run(config)
  File "/Users/filletofish/Dev/DataMiningEcon/src/twint/twint/run.py", line 167, in run
    get_event_loop().run_until_complete(Twint(config).main())
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 573, in run_until_complete
    return future.result()
  File "/Users/filletofish/Dev/DataMiningEcon/src/twint/twint/run.py", line 127, in main
    self.config.User_id = await get.User(url, self.config, self.conn, True)
  File "/Users/filletofish/Dev/DataMiningEcon/src/twint/twint/get.py", line 144, in User
    return int(inf(soup, "id"))
  File "/Users/filletofish/Dev/DataMiningEcon/src/twint/twint/user.py", line 16, in inf
    ret = group["data-user-id"]
TypeError: 'NoneType' object is not subscriptable

Environment Details

Mac OS 10.14, zsh

pielco11 commented 5 years ago

Hi @filletofish,

you are having that error because that account is suspended, as you may check here.

Please try with a different username.

In case of further issues feel free to re-open

filletofish commented 5 years ago

@pielco11 thank you for your help! Much appreciate it. I believe in future it would be good to update README to avoid confusions.

ZiyadMoraished commented 5 years ago

Hi @filletofish,

you are having that error because that account is suspended, as you may check here.

Please try with a different username.

In case of further issues feel free to re-open

This twitter account @AlArabiya_Brk is not suspended and i'm still getting the same error.

code:

import twint
c = twint.Config()
c.Username = "AlArabiya_Brk"

twint.run.Profile(c)

output: 'NoneType' object is not subscriptable [x] get.User

pielco11 commented 5 years ago

@ZiyadMoraished I'm going to open a new issue for that

pielco11 commented 5 years ago

326

ZiyadMoraished commented 5 years ago

@ZiyadMoraished I'm going to open a new issue for that

Thanks @pielco11

well, once I updated the library to 1.2.1, everything started to wok fine.

Linasunshine commented 4 years ago

It seems not working for twint installed from Git repo. If you install from pip (i.e. pip3 install twint), you won't have this error anymore.

pielco11 commented 4 years ago

May you share the commit id, @Linasunshine , please? So that we have a ref

Linasunshine commented 4 years ago

I got the same error message 'NoneType' object is not subscribable' and the answer from #763 solved my issue. You can have a look and see if it works for your case. Question: ValueError: Cannot find twitter account with name = realDonaldTrump #763