twint
twint copied to clipboard
Language filter problem fixed
The Language filter issue discussed in #1015 has been fixed.
So, @himanshudabas 's fix work, but need lang to be explictly defined.
if config.Search:
if config.Lang:
q += f" {config.Search} lang:{config.Lang}"
else:
q += f" {config.Search}"
So this could work better I suppose. (in case lang is not defined, return all languages.)
@innocentius Can you please try to run it again with the changes I suggested.
In my comment I mentioned that @hshafiq132 would need to revert his changes before adding my suggested changes.
So the final code would look something like
101 if conif.Lang:
102 q += f" lang:{config.Lang}"
110 if config.Search:
111 q += f" {config.Search}"
Let me know if it works now.
@himanshudabas Yea, yours would look much better.
With this version, I am getting "Could not find the Guest token in HTML" error. Can you please fix the conflicts and merge this branch. This will help me too much
@aburak256 That is already fixed in the latest update. Since the current updates couldn't follow the need of users, I created another branch in case anyone need to use it. try install from https://github.com/innocentius/twint
Hi all,
The language filter still doesn't work for me after making the suggested changes. I really struggle with that issue. May be I'm missing something important.
Here is what I've done several times :
- I clone https://github.com/twintproject/twint.git locally
- I make the suggested change, i.e. replace Lines 102 & 103 in url.py with
q += f" lang:{config.Lang}"
- I install twint using pip install . in my twint folder
Then, when I use the filter language in my notebook, it still gives me all languages. The code I'm using is the following :
c = twint.Config()
c.Search = 'bitcoin'
c.Lang = 'fr
c.Output = './test.csv'
c.Store_csv = True
Could you please help me ?
Thanks !
@etiennesim Try setting it directly in your packages library. Type "pip show twint" into the command line, follow the path shown at "Location", then open the folder named "twint" and change these lines
101 if conif.Lang:
102 q += f" lang:{config.Lang}"
110 if config.Search:
111 q += f" {config.Search}"
as shown by @himanshudabas and see if that solves your issue.
@JWLMSN It would be config in line 101 and the file is urls.py (for anyone looking).
101 if config.Lang:
102 q += f" lang:{config.Lang}"
110 if config.Search:
111 q += f" {config.Search}"
Hi @hshafiq132, @KazimTibetSar and @himanshudabas
I would like to know how is the update regarding this Pull Request? a friend of mine tried latest release of twint, and still got the language filter is not working.
I tried following @JWLMSN and @prkhrv solution and it works, by adding few lines on url.py
file. on line 110 (its no longer line 101).
I asked my friend to add few lines starting 110 on url.py
so that it become like this:
108 if config.Geo:
109 config.Geo = config.Geo.replace(" ", "")
110 q += f" geocode:{config.Geo}"
111 + if config.Lang:
112 + q += f" lang:{config.Lang}"
111 113 if config.Search:
112 114
113 115 q += f" {config.Search}"
and it works
let me know if there is something I could help so that this issue can be solved and more people can use language filter without having to modify the url.py
directly, thanks!
Thank you, saved me.