Giter Site home page Giter Site logo

Comments (4)

ralfian avatar ralfian commented on August 15, 2024

Same here, i need to mining in non-english text also, please help us.
Thanks!

from twitterscraper.

ralfian avatar ralfian commented on August 15, 2024

alternative solution is use location of the non-english city.

from twitterscraper.

aliyudin21 avatar aliyudin21 commented on August 15, 2024

You can write a script in your Python intepreter like following :

from twitterscraper import query_tweets

for tweet in query_tweets('your keyword', 10)[:10]:
    text = tweet.text.encode('utf-8')
    user = tweet.user.encode('utf-8')
   
    xfile = 'F:/tweets.txt'    #you can create your own .json in your own path 
    with open(xfile, 'ab+') as f:    #ab+ is to write in the end position of the file (appending) 
        f.seek(0)
        f.write(text+'\n')    #you need '\n' to make new line for incoming tweets 
        f.write(user+'\n')

Hope it helps.

from twitterscraper.

taspinar avatar taspinar commented on August 15, 2024

@zdw-chj @ralfian @aliyudin21
The twitterscraper as it is, should work properly with non-english characters.

The thing is, when the text is saved to file, it is saved as the utf-8 encoded bytes of these characters instead of the actual characters.

So when you scrape for "戦う", the contents of the file will indeed look something like ""\u30b1\u30f3\u3055\u307e\u30fe ..."

so what you should do is open this file with the proper encoding

import codecs, json
filename = 'chinese.json'
with codecs.open(filename, 'r', 'utf-8') as f:
    tweets = json.load(f, encoding='utf-8')

See example below:

chinese_characters

from twitterscraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.