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 ...@@ -12,7 +12,7 @@ twint/storage/mysql.py
# Node Dependency directories # Node Dependency directories
node_modules/ node_modules/
jspm_packages/ jspm_packages/
tests/
# Distribution / packaging # Distribution / packaging
.Python .Python
env/ env/
......
...@@ -34,7 +34,8 @@ Twitter limits scrolls while browsing the user timeline. This means that with `. ...@@ -34,7 +34,8 @@ Twitter limits scrolls while browsing the user timeline. This means that with `.
- aiohttp_socks; - aiohttp_socks;
- schedule; - schedule;
- geopy; - geopy;
- fake-useragent. - fake-useragent;
- py-googletransx.
## Installing ## Installing
...@@ -172,9 +173,34 @@ Twitter can shadow-ban accounts, which means that their tweets will not be avail ...@@ -172,9 +173,34 @@ Twitter can shadow-ban accounts, which means that their tweets will not be avail
`twint --userlist inputlist --user-full` `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: ## Featured Blog Posts:
- [How to use Twint as an OSINT tool](https://pielco11.ovh/posts/twint-osint/) - [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/) - [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) - [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/) - [Loading tweets into Kafka and Neo4j](https://markhneedham.com/blog/2019/05/29/loading-tweets-twint-kafka-neo4j/)
......
...@@ -9,4 +9,4 @@ aiohttp_socks ...@@ -9,4 +9,4 @@ aiohttp_socks
schedule schedule
geopy geopy
fake-useragent fake-useragent
googletrans googletransx
\ No newline at end of file
...@@ -17,7 +17,7 @@ VERSION = None ...@@ -17,7 +17,7 @@ VERSION = None
REQUIRED = [ REQUIRED = [
'aiohttp', 'aiodns', 'beautifulsoup4', 'cchardet', 'aiohttp', 'aiodns', 'beautifulsoup4', 'cchardet',
'elasticsearch', 'pysocks', 'pandas', 'aiohttp_socks', 'elasticsearch', 'pysocks', 'pandas', 'aiohttp_socks',
'schedule', 'geopy', 'fake-useragent','googletrans' 'schedule', 'geopy', 'fake-useragent', 'googletransx'
] ]
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
...@@ -50,6 +50,9 @@ setup( ...@@ -50,6 +50,9 @@ setup(
], ],
}, },
install_requires=REQUIRED, install_requires=REQUIRED,
dependency_links=[
'git+https://github.com/x0rzkov/py-googletrans#egg=googletrans'
],
license='MIT', license='MIT',
classifiers=[ classifiers=[
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',
......
...@@ -3,7 +3,7 @@ from datetime import datetime ...@@ -3,7 +3,7 @@ from datetime import datetime
import json import json
import logging as logme import logging as logme
from googletrans import Translator from googletransx import Translator
# ref. # ref.
# - https://github.com/x0rzkov/py-googletrans#basic-usage # - https://github.com/x0rzkov/py-googletrans#basic-usage
...@@ -120,6 +120,6 @@ def Tweet(tw, config): ...@@ -120,6 +120,6 @@ def Tweet(tw, config):
t.trans_dest = ts.dest t.trans_dest = ts.dest
# ref. https://github.com/SuniTheFish/ChainTranslator/blob/master/ChainTranslator/__main__.py#L31 # ref. https://github.com/SuniTheFish/ChainTranslator/blob/master/ChainTranslator/__main__.py#L31
except ValueError as e: 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)) logme.debug(__name__+':Tweet:translator.translate:'+str(e))
return t 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