Commit 7ea55b2a authored by x0rzkov's avatar x0rzkov Committed by Francesco Poldi

google translate update (#590)

* update README with gtranslate example (cli and python)

* switch to fork py-googletrans

* update README.md
parent 11fdcd03
......@@ -12,7 +12,7 @@ twint/storage/mysql.py
# Node Dependency directories
node_modules/
jspm_packages/
tests/
# Distribution / packaging
.Python
env/
......
......@@ -34,7 +34,8 @@ Twitter limits scrolls while browsing the user timeline. This means that with `.
- aiohttp_socks;
- schedule;
- geopy;
- fake-useragent.
- fake-useragent;
- py-googletransx.
## Installing
......@@ -172,9 +173,34 @@ Twitter can shadow-ban accounts, which means that their tweets will not be avail
`twint --userlist inputlist --user-full`
#### tweet translation (experimental)
> To get 100 english tweets and translate them to italian
`twint -u noneprivacy --csv --output none.csv --lang en --translate --translate-dest it --limit 100`
or
```python
import twint
c = twint.Config()
c.Username = "noneprivacy"
c.Limit = 100
c.Store_csv = True
c.Output = "none.csv"
c.Lang = "en"
c.Translate = True
c.TranslateDest = "it"
twint.run.Search(c)
```
Notes:
- [Google translate has some quotas](https://cloud.google.com/translate/quotas)
## Featured Blog Posts:
- [How to use Twint as an OSINT tool](https://pielco11.ovh/posts/twint-osint/)
- [Hunting Threats On Twitter](https://www.trendmicro.com/vinfo/us/security/news/cybercrime-and-digital-threats/hunting-threats-on-twitter)
- [Basic tutorial made by Null Byte](https://null-byte.wonderhowto.com/how-to/mine-twitter-for-targeted-information-with-twint-0193853/)
- [Analyzing Tweets with NLP in minutes with Spark, Optimus and Twint](https://towardsdatascience.com/analyzing-tweets-with-nlp-in-minutes-with-spark-optimus-and-twint-a0c96084995f)
- [Loading tweets into Kafka and Neo4j](https://markhneedham.com/blog/2019/05/29/loading-tweets-twint-kafka-neo4j/)
......
......@@ -9,4 +9,4 @@ aiohttp_socks
schedule
geopy
fake-useragent
googletrans
\ No newline at end of file
googletransx
......@@ -17,7 +17,7 @@ VERSION = None
REQUIRED = [
'aiohttp', 'aiodns', 'beautifulsoup4', 'cchardet',
'elasticsearch', 'pysocks', 'pandas', 'aiohttp_socks',
'schedule', 'geopy', 'fake-useragent','googletrans'
'schedule', 'geopy', 'fake-useragent', 'googletransx'
]
here = os.path.abspath(os.path.dirname(__file__))
......@@ -50,6 +50,9 @@ setup(
],
},
install_requires=REQUIRED,
dependency_links=[
'git+https://github.com/x0rzkov/py-googletrans#egg=googletrans'
],
license='MIT',
classifiers=[
'License :: OSI Approved :: MIT License',
......
......@@ -3,7 +3,7 @@ from datetime import datetime
import json
import logging as logme
from googletrans import Translator
from googletransx import Translator
# ref.
# - https://github.com/x0rzkov/py-googletrans#basic-usage
......@@ -120,6 +120,6 @@ def Tweet(tw, config):
t.trans_dest = ts.dest
# ref. https://github.com/SuniTheFish/ChainTranslator/blob/master/ChainTranslator/__main__.py#L31
except ValueError as e:
# raise Exception("Invalid destination language: {}".format(config.TranslateDest))
raise Exception("Invalid destination language: {} / Tweet: {}".format(config.TranslateDest, t.tweet))
logme.debug(__name__+':Tweet:translator.translate:'+str(e))
return t
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment