twint icon indicating copy to clipboard operation
twint copied to clipboard

Language filter problem fixed

Open hshafiq132 opened this issue 4 years ago • 10 comments

The Language filter issue discussed in #1015 has been fixed.

hshafiq132 avatar Nov 11 '20 06:11 hshafiq132

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 avatar Dec 17 '20 07:12 innocentius

@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 avatar Dec 17 '20 08:12 himanshudabas

@himanshudabas Yea, yours would look much better.

innocentius avatar Dec 17 '20 09:12 innocentius

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 avatar Dec 25 '20 14:12 aburak256

@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

innocentius avatar Dec 26 '20 00:12 innocentius

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 avatar Jul 30 '21 10:07 etiennesim

@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 avatar Sep 18 '21 21:09 JWLMSN

@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}" 

prkhrv avatar Nov 25 '21 19:11 prkhrv

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!

ridhof avatar Apr 03 '22 08:04 ridhof

Thank you, saved me.

jbajric avatar May 18 '22 23:05 jbajric