Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Error getting tweets #938

Open
DavidPerea opened this issue Oct 6, 2020 · 10 comments
Open

Error getting tweets #938

DavidPerea opened this issue Oct 6, 2020 · 10 comments

Comments

@DavidPerea
Copy link

I have reinstalled Twint using the github command: pip3 install --user --upgrade git+https://github.com/twintproject/twint.git@origin/master#egg=twint

I try to get the tweets in this way: twint -u username and it returns the following error:

Traceback (most recent call last): File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\DavidPerea\AppData\Local\Programs\Python\Python37-32\Scripts\twint.exe\__main__.py", line 5, in <module> File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\__init__.py", line 14, in <module> from . import run File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 4, in <module> from . import datelock, feed, get, output, verbose, storage File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 12, in <module> from aiohttp_socks import ProxyConnector, ProxyType ImportError: cannot import name 'ProxyConnector' from 'aiohttp_socks' (c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp_socks\__init__.py)

What can I do, please?

@hj5992
Copy link

hj5992 commented Oct 12, 2020

I am getting the same error. Is there any solution for this?

@himanshudabas
Copy link
Contributor

This seems to be an issue with your aiohttp_socks package.
Can you try to do a fresh install on a virtual environment?

@hj5992
Copy link

hj5992 commented Oct 27, 2020

you need to update the aiohttp_socks to 0.5.5 version and this will work

@DavidPerea
Copy link
Author

How is that package updated? I'm sorry because I'm still inexperienced at this. Thank you very much!

@hj5992
Copy link

hj5992 commented Oct 28, 2020

pip install --user --upgrade aiohttp_socks

@DavidPerea
Copy link
Author

It has been updated successfully. Run the twint command again twint -u username and it returns this error:

Traceback (most recent call last):
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\Scripts\twint.exe\__main__.py", line 7, in <module>
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\cli.py", line 313, in run_as_command
    main()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\cli.py", line 305, in main
    run.Search(c)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 427, in Search
    run(config, callback)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 319, in run
    get_event_loop().run_until_complete(Twint(config).main(callback))
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\asyncio\base_events.py", line 573, in run_until_complete
    return future.result()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 239, in main
    await task
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 290, in run
    await self.tweets()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 221, in tweets
    await self.Feed()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 61, in Feed
    response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 141, in RequestUrl
    response = await Request(_url, params=params, connector=_connector, headers=_headers)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 167, in Request
    return await Response(session, _url, params)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 173, in Response
    async with session.get(_url, ssl=True, params=params, proxy=httpproxy) as response:
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client.py", line 855, in __aenter__
    self._resp = await self._coro
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client.py", line 361, in _request
    ssl=ssl, proxy_headers=proxy_headers, traces=traces)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client_reqrep.py", line 207, in __init__
    url2 = url.with_query(params)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 857, in with_query
    new_query = self._get_str_query(*args, **kwargs)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 837, in _get_str_query
    for k, v in query)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 837, in <genexpr>
    for k, v in query)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\quoting.py", line 29, in __call__
    raise TypeError("Argument should be str")
TypeError: Argument should be str

@himanshudabas
Copy link
Contributor

Try the following steps and see if your issue gets fixed

  1. create a new folder somewhere, like on your desktop and open powershell there.
  2. run the following command python -m venv venv
  3. .\venv\Scripts\activate (after this you should be in the virtual environment)
  4. pip3 install --upgrade git+https://github.com/himanshudabas/twint.git@origin/master#egg=twint
  5. now try running the following command from command line twint -u realDonaldTrump

Let me know if this works for you.

@TangCaijin
Copy link

It has been updated successfully. Run the twint command again twint -u username and it returns this error:

Traceback (most recent call last):
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\Scripts\twint.exe\__main__.py", line 7, in <module>
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\cli.py", line 313, in run_as_command
    main()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\cli.py", line 305, in main
    run.Search(c)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 427, in Search
    run(config, callback)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 319, in run
    get_event_loop().run_until_complete(Twint(config).main(callback))
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\asyncio\base_events.py", line 573, in run_until_complete
    return future.result()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 239, in main
    await task
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 290, in run
    await self.tweets()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 221, in tweets
    await self.Feed()
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\run.py", line 61, in Feed
    response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 141, in RequestUrl
    response = await Request(_url, params=params, connector=_connector, headers=_headers)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 167, in Request
    return await Response(session, _url, params)
  File "C:\Users\DavidPerea\AppData\Roaming\Python\Python37\site-packages\twint\get.py", line 173, in Response
    async with session.get(_url, ssl=True, params=params, proxy=httpproxy) as response:
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client.py", line 855, in __aenter__
    self._resp = await self._coro
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client.py", line 361, in _request
    ssl=ssl, proxy_headers=proxy_headers, traces=traces)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\aiohttp\client_reqrep.py", line 207, in __init__
    url2 = url.with_query(params)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 857, in with_query
    new_query = self._get_str_query(*args, **kwargs)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 837, in _get_str_query
    for k, v in query)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\__init__.py", line 837, in <genexpr>
    for k, v in query)
  File "c:\users\davidperea\appdata\local\programs\python\python37-32\lib\site-packages\yarl\quoting.py", line 29, in __call__
    raise TypeError("Argument should be str")
TypeError: Argument should be str

Have you solved the problem(TypeError: Argument should be str)? I have the same problem now

@seanPhill
Copy link

seanPhill commented Apr 17, 2022

I'm getting errors like this on every command I've tried. Only installed from the master branch (on macOS 12.0.1 with Python 3.9.12) today.
Is this also related to aiohttp_socks? I think it shouldn't be, as it was installed for the first time, with twint today.

Traceback (most recent call last):
  File "/usr/local/bin/twint", line 5, in <module>
    from twint.cli import run_as_command
  File "/usr/local/lib/python3.9/site-packages/twint/__init__.py", line 14, in <module>
    from . import run
  File "/usr/local/lib/python3.9/site-packages/twint/run.py", line 4, in <module>
    from . import datelock, feed, get, output, verbose, storage
  File "/usr/local/lib/python3.9/site-packages/twint/get.py", line 12, in <module>
    from aiohttp_socks import ProxyConnector, ProxyType
  File "/usr/local/lib/python3.9/site-packages/aiohttp_socks/__init__.py", line 5, in <module>
    from .connector import (
  File "/usr/local/lib/python3.9/site-packages/aiohttp_socks/connector.py", line 8, in <module>
    from aiohttp.helpers import CeilTimeout  # noqa
ImportError: cannot import name 'CeilTimeout' from 'aiohttp.helpers' (/usr/local/lib/python3.9/site-packages/aiohttp/helpers.py)

An example of the command used is the following, ... someone only following a couple of hundred accounts.

twint -u AusElectoralCom --following

@seanPhill
Copy link

seanPhill commented Apr 17, 2022

I'm following up this comment

To fix it you must to have fixed version on aiohttp.
Edit requeriments.txt with aiohttp==3.7.0

in #1297 (even though typos are always a concern!)

--> #1299

... I have less errors now! (Only one!)

twint -u AusElectoralCom --following
CRITICAL:root:twint.feed:Follow:IndexError

#1206 suggests that this particular search (to list following") can't be done anymore without Twitter logged in. (Twitter changed) I don't see an option to log in, with twint -h.

It does however work for listing tweets, and it got a lot, as that (Electoral Commission) account seems to be employed to continually Tweet, at least as an election has already been called.

 twint -u AusElectoralCom --since 2022-04-14

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants