1

I have to collect some data from Twitter via Search. Unfortunately, its not possible to get Twitter API as they have rejected my request many times. I have decided to use twint python module for this purpose. I have installed latest version via git and then tried to search tweets for a string as follows:

twint -s pineapple

I get this exception

Traceback (most recent call last):

File "/usr/local/bin/twint", line 33, in
sys.exit(load_entry_point('twint==2.1.21', 'console_scripts', 'twint')())

File "/usr/local/lib/python3.6/dist-packages/twint/cli.py", line 339, in run_as_command
main()

File "/usr/local/lib/python3.6/dist-packages/twint/cli.py", line 330, in main
run.Search(c)

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 410, in Search
run(config, callback)

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 329, in run
get_event_loop().run_until_complete(Twint(config).main(callback))

File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 235, in main
await task

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 286, in run
await self.tweets()

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 217, in tweets
await self.Feed()

File "/usr/local/lib/python3.6/dist-packages/twint/run.py", line 62, in Feed
response = await get.RequestUrl(self.config, self.init)

File "/usr/local/lib/python3.6/dist-packages/twint/get.py", line 135, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=_headers)

File "/usr/local/lib/python3.6/dist-packages/twint/get.py", line 161, in Request
return await Response(session, _url, params)

File "/usr/local/lib/python3.6/dist-packages/twint/get.py", line 167, in Response
async with session.get(_url, ssl=True, params=params, proxy=httpproxy) as response:

File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 855, in aenter
self._resp = await self._coro

File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 361, in _request
ssl=ssl, proxy_headers=proxy_headers, traces=traces)

File "/usr/local/lib/python3.6/dist-packages/aiohttp/client_reqrep.py", line 207, in init
url2 = url.with_query(params)

File "/usr/local/lib/python3.6/dist-packages/yarl/init.py", line 857, in with_query
new_query = self._get_str_query(*args, **kwargs)

File "/usr/local/lib/python3.6/dist-packages/yarl/init.py", line 837, in _get_str_query
for k, v in query)

File "/usr/local/lib/python3.6/dist-packages/yarl/init.py", line 837, in
for k, v in query)

File "yarl/_quoting.pyx", line 226, in yarl._quoting._Quoter.call

TypeError: Argument should be str

The installed version of python on my Ubuntu is 3.6. I have also imported twint in Python script but same exception appeared there also.

How to fix this issue ? Is there any best alternate for this task ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Hafiz Muhammad Shafiq
  • 8,168
  • 12
  • 63
  • 121

2 Answers2

2

I had the same issue with python3.7 and resolve it by reinstalling yarl, like this way:

pip3 install yarl --force-reinstall --no-cache-dir
freeearth
  • 91
  • 1
  • 10
1

Uninstall twint Using the pip uninstall twint

and then reinstall it using

pip install "git+https://github.com/twintproject/twint.git@origin/master#egg=twint"

Hope this works

P.S. Incase you are using jupyter notebook try using the pip commands in the anaconda prompt.