Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Twint
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Twint
Commits
1cb40f0c
Commit
1cb40f0c
authored
May 26, 2018
by
Cody Zacharias
Committed by
GitHub
May 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add retweets option
parent
a7274069
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
136 deletions
+138
-136
Twint.py
Twint.py
+138
-136
No files found.
Twint.py
View file @
1cb40f0c
#!/usr/bin/python3
'''
Twint.py - Twitter Intelligence (formerly known as Tweep).
Written by Cody Zacharias (@now)
Special thanks to @hpiedcoq & @pielco11 for contributing
several search and storing options.
Twint.py - Twitter Intelligence Tool (formerly known as Tweep).
See wiki on Github for in-depth details.
https://github.com/haccer/twint/wiki
...
...
@@ -22,13 +18,17 @@ def error(error, message):
sys
.
exit
(
0
)
def
check
(
args
):
# Error checking
if
args
.
username
is
not
None
:
if
args
.
users
:
error
(
"Contradicting Args"
,
"Please use --users in combination with -s."
)
error
(
"Contradicting Args"
,
"Please use --users in combination with -s."
)
if
args
.
verified
:
error
(
"Contradicting Args"
,
"Please use --verified in combination with -s."
)
error
(
"Contradicting Args"
,
"Please use --verified in combination with -s."
)
if
args
.
userid
:
error
(
"Contradicting Args"
,
"--userid and -u cannot be used together."
)
error
(
"Contradicting Args"
,
"--userid and -u cannot be used together."
)
if
args
.
tweets
and
args
.
users
:
error
(
"Contradicting Args"
,
"--users and --tweets cannot be used together."
)
if
args
.
csv
and
args
.
output
is
None
:
...
...
@@ -46,19 +46,19 @@ def check(args):
elif
args
.
proxy_type
.
lower
()
==
"http"
:
_type
=
socks
.
HTTP
else
:
error
(
"Error"
,
"Proxy type allowed are: socks5, socks4
and http."
)
error
(
"Error"
,
"Proxy types allowed are: socks5, socks4,
and http."
)
import
socks
,
socket
socks
.
set_default_proxy
(
_type
,
args
.
proxy_host
,
int
(
args
.
proxy_port
))
socket
.
socket
=
socks
.
socksocket
else
:
error
(
"Error"
,
"Please specify --proxy-host, --proxy-port
and --proxy-type"
)
error
(
"Error"
,
"Please specify --proxy-host, --proxy-port,
and --proxy-type"
)
else
:
if
args
.
proxy_port
or
args
.
proxy_type
:
error
(
"Error"
,
"Please specify --proxy-host, --proxy-port
and --proxy-type"
)
error
(
"Error"
,
"Please specify --proxy-host, --proxy-port,
and --proxy-type"
)
def
loadUserList
(
ul
):
if
os
.
path
.
exists
(
os
.
path
.
abspath
(
ul
)):
userlist
=
open
(
os
.
path
.
abspath
(
ul
),
"r"
)
.
read
()
.
splitlines
(
)
userlist
=
open
(
os
.
path
.
abspath
(
ul
),
"r"
.
read
()
.
splitlines
()
)
else
:
userlist
=
ul
.
split
(
","
)
un
=
""
...
...
@@ -66,7 +66,6 @@ def loadUserList(ul):
un
+=
"
%20
OR
%20
from
%3
A"
+
user
return
un
[
15
:]
def
initialize
(
args
):
c
=
twint
.
Config
()
c
.
Username
=
args
.
username
...
...
@@ -95,51 +94,52 @@ def initialize(args):
c
.
Database
=
args
.
database
c
.
To
=
args
.
to
c
.
All
=
args
.
all
c
.
Debug
=
args
.
debug
c
.
Proxy_type
=
args
.
proxy_type
c
.
Proxy_host
=
args
.
proxy_host
c
.
Proxy_port
=
args
.
proxy_port
#c.Debug = args.debug
c
.
Essid
=
args
.
essid
c
.
Userlist
=
args
.
userlist
return
c
def
options
():
ap
=
argparse
.
ArgumentParser
(
prog
=
"twint.py"
,
usage
=
"python3
%(prog)
s [options]"
,
description
=
"TWINT - An Advanced Twitter Scraping Tool"
)
ap
=
argparse
.
ArgumentParser
(
prog
=
"Twint.py"
,
usage
=
"python3
%(prog)
s [options]"
,
description
=
"TWINT - An Advanced Twitter Scraping Tool."
)
ap
.
add_argument
(
"-u"
,
"--username"
,
help
=
"User's Tweets you want to scrape."
)
ap
.
add_argument
(
"-s"
,
"--search"
,
help
=
"Search for Tweets containing this word or phrase."
)
ap
.
add_argument
(
"-g"
,
"--geo"
,
help
=
"Search for geocoded t
weets."
)
ap
.
add_argument
(
"-g"
,
"--geo"
,
help
=
"Search for geocoded T
weets."
)
ap
.
add_argument
(
"--near"
,
help
=
"Near a specified city."
)
ap
.
add_argument
(
"--location"
,
help
=
"Show user's location (Experimental)."
,
action
=
"store_true"
)
ap
.
add_argument
(
"-l"
,
"--lang"
,
help
=
"Serch for Tweets in a specific language
"
)
ap
.
add_argument
(
"-l"
,
"--lang"
,
help
=
"Search for Tweets in a specific language.
"
)
ap
.
add_argument
(
"-o"
,
"--output"
,
help
=
"Save output to a file."
)
ap
.
add_argument
(
"-es"
,
"--elasticsearch"
,
help
=
"Index to Elasticsearch
"
)
ap
.
add_argument
(
"-t"
,
"--timedelta"
,
help
=
"Time interval for every request
"
)
ap
.
add_argument
(
"-es"
,
"--elasticsearch"
,
help
=
"Index to Elasticsearch.
"
)
ap
.
add_argument
(
"-t"
,
"--timedelta"
,
help
=
"Time interval for every request.
"
)
ap
.
add_argument
(
"--year"
,
help
=
"Filter Tweets before specified year."
)
ap
.
add_argument
(
"--since"
,
help
=
"Filter Tweets sent since date (Example: 2017-12-27)."
)
ap
.
add_argument
(
"--until"
,
help
=
"Filter Tweets sent until date (Example: 2017-12-27)."
)
ap
.
add_argument
(
"--fruit"
,
help
=
"Display 'low-hanging-fruit' Tweets."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--tweets"
,
help
=
"Display Tweets only."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--verified"
,
help
=
"Display Tweets only from verified users (Use with -s)."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--verified"
,
help
=
"Display Tweets only from verified users (Use with -s)."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--users"
,
help
=
"Display users only (Use with -s)."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--csv"
,
help
=
"Write as .csv file."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--json"
,
help
=
"Write as .json file.
"
,
action
=
"store_true"
)
ap
.
add_argument
(
"--json"
,
help
=
"Write as .json file
"
,
action
=
"store_true"
)
ap
.
add_argument
(
"--hashtags"
,
help
=
"Output hashtags in seperate column."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--userid"
,
help
=
"Twitter user id
"
)
ap
.
add_argument
(
"--userid"
,
help
=
"Twitter user id.
"
)
ap
.
add_argument
(
"--limit"
,
help
=
"Number of Tweets to pull (Increments of 20)."
)
ap
.
add_argument
(
"--count"
,
help
=
"Display number Tweets scraped at the end of session."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--stats"
,
help
=
"Show number of replies, retweets, and likes"
,
action
=
"store_true"
)
ap
.
add_argument
(
"--database"
,
help
=
"Store tweets in the database"
)
ap
.
add_argument
(
"--to"
,
help
=
"Search Tweets to a user"
)
ap
.
add_argument
(
"--all"
,
help
=
"Search all Tweets associated with a user"
)
ap
.
add_argument
(
"--followers"
,
help
=
"Scrape a person's followers"
,
action
=
"store_true"
)
ap
.
add_argument
(
"--following"
,
help
=
"Scrape who a person follows."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--count"
,
help
=
"Display number of Tweets scraped at the end of session."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--stats"
,
help
=
"Show number of replies, retweets, and likes."
,
action
=
"store_true"
)
ap
.
add_argument
(
"-db"
,
"--database"
,
help
=
"Store Tweets in a sqlite3 database."
)
ap
.
add_argument
(
"--to"
,
help
=
"Search Tweets to a user."
)
ap
.
add_argument
(
"--all"
,
help
=
"Search all Tweets associated with a user."
)
ap
.
add_argument
(
"--followers"
,
help
=
"Scrape a person's followers."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--following"
,
help
=
"Scrape a person's follows"
,
action
=
"store_true"
)
ap
.
add_argument
(
"--favorites"
,
help
=
"Scrape Tweets a user has liked."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--debug"
,
help
=
"Debug mode"
,
action
=
"store_true"
)
#
ap.add_argument("--debug", help="Debug mode", action="store_true")
ap
.
add_argument
(
"--proxy-type"
,
help
=
"Socks5, HTTP, etc."
)
ap
.
add_argument
(
"--proxy-host"
,
help
=
"Proxy hostname or IP."
)
ap
.
add_argument
(
"--proxy-port"
,
help
=
"The port of the proxy server."
)
ap
.
add_argument
(
"--essid"
,
help
=
"Elasticsearch Session ID, use this to differentiate scraping sessions."
)
ap
.
add_argument
(
"--userlist"
,
help
=
"Userlist from list or file."
)
ap
.
add_argument
(
"--retweets"
,
help
=
"Include user's Retweets (Warning: limited)."
,
action
=
"store_true"
)
args
=
ap
.
parse_args
()
return
args
...
...
@@ -158,6 +158,8 @@ def main():
twint
.
Following
(
c
)
elif
args
.
followers
:
twint
.
Followers
(
c
)
elif
args
.
retweets
:
twint
.
Profile
(
c
)
else
:
twint
.
Search
(
c
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment