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
3fce83dc
Commit
3fce83dc
authored
May 26, 2018
by
Cody Zacharias
Committed by
GitHub
May 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update following.py
parent
06bf75da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
54 deletions
+57
-54
twint/following.py
twint/following.py
+57
-54
No files found.
twint/following.py
View file @
3fce83dc
from
.
import
feed
,
get
,
db
,
output
,
elasticsearch
from
bs4
import
BeautifulSoup
import
aiohttp
import
asyncio
import
re
import
sys
class
Following
:
def
__init__
(
self
,
config
):
self
.
init
=
-
1
self
.
feed
=
[
-
1
]
self
.
count
=
0
self
.
config
=
config
def
__init__
(
self
,
config
):
self
.
init
=
-
1
self
.
feed
=
[
-
1
]
self
.
count
=
0
self
.
config
=
config
if
self
.
config
.
Database
:
print
(
"Inserting into Database: "
+
str
(
self
.
config
.
Database
))
self
.
conn
=
db
.
init
(
self
.
config
.
Database
)
if
isinstance
(
self
.
conn
,
str
):
print
(
str
)
sys
.
exit
(
1
)
loop
=
asyncio
.
get_event_loop
()
loop
.
run_until_complete
(
self
.
main
())
if
self
.
config
.
Elasticsearch
:
print
(
"[+] Indexing to Elasticsearch @ "
+
str
(
self
.
config
.
Elasticsearch
))
async
def
Feed
(
self
):
ua
=
{
'User-Agent'
:
'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/0.8.12'
}
connect
=
aiohttp
.
TCPConnector
(
verify_ssl
=
False
)
async
with
aiohttp
.
ClientSession
(
headers
=
ua
,
connector
=
connect
)
as
session
:
response
=
await
get
.
Response
(
session
,
await
get
.
Url
(
self
.
config
,
self
.
init
)
.
following
())
self
.
feed
=
[]
try
:
self
.
feed
,
self
.
init
=
feed
.
Follow
(
response
)
except
Exception
as
e
:
pass
return
self
.
feed
if
self
.
config
.
Database
:
print
(
"[+] Inserting into Database: "
+
str
(
self
.
config
.
Database
))
self
.
conn
=
db
.
init
(
self
.
config
.
Database
)
if
isinstance
(
self
.
conn
,
str
):
print
(
str
)
sys
.
exit
(
1
)
async
def
following
(
self
):
await
self
.
Feed
()
for
f
in
self
.
feed
:
User
=
await
output
.
getUser
(
f
)
if
self
.
config
.
Database
:
db
.
following
(
self
.
conn
,
self
.
config
.
Username
,
User
.
name
)
loop
=
asyncio
.
get_event_loop
()
loop
.
run_until_complete
(
self
.
main
())
async
def
Feed
(
self
):
url
=
await
get
.
Url
(
self
.
config
,
self
.
init
)
.
following
()
response
=
await
get
.
MobileRequest
(
self
.
config
,
url
)
self
.
feed
=
[]
try
:
self
.
feed
,
self
.
init
=
feed
.
Follow
(
response
)
except
Exception
as
e
:
pass
if
self
.
config
.
Output
!=
None
:
output
.
write
(
User
.
name
,
self
.
config
.
Output
)
if
self
.
config
.
Elasticsearch
:
elasticsearch
.
Follow
(
self
.
config
.
Elasticsearch
,
self
.
config
.
Username
,
User
.
name
,
self
.
config
.
Essid
)
self
.
count
+=
1
print
(
User
.
name
)
return
self
.
feed
async
def
main
(
self
):
if
self
.
config
.
User_id
is
not
None
:
self
.
config
.
Username
=
await
get
.
Username
(
self
.
config
.
User_id
)
while
True
:
if
len
(
self
.
feed
)
>
0
:
await
self
.
following
()
else
:
break
if
self
.
config
.
Limit
is
not
None
and
self
.
count
>=
int
(
self
.
config
.
Limit
):
break
async
def
following
(
self
):
await
self
.
Feed
()
for
f
in
self
.
feed
:
User
=
await
output
.
getUser
(
f
)
if
self
.
config
.
Database
:
db
.
following
(
self
.
conn
,
self
.
config
.
Username
,
User
.
name
)
if
self
.
config
.
Count
:
print
(
"[+] Finished: Successfully collected all {0.count} users who @{0.config.Username} follows."
.
format
(
self
))
if
self
.
config
.
Output
!=
None
:
output
.
write
(
User
.
name
,
self
.
config
.
Output
)
if
self
.
config
.
Elasticsearch
:
elasticsearch
.
Follow
(
self
.
config
.
Elasticsearch
,
self
.
config
.
Username
,
User
.
name
,
self
.
config
.
Essid
)
self
.
count
+=
1
print
(
User
.
name
)
async
def
main
(
self
):
if
self
.
config
.
User_id
is
not
None
:
self
.
config
.
Username
=
await
get
.
Username
(
self
.
config
)
while
True
:
if
len
(
self
.
feed
)
>
0
:
await
self
.
following
()
else
:
break
if
self
.
config
.
Limit
is
not
None
and
self
.
count
>=
int
(
self
.
config
.
Limit
):
break
if
self
.
config
.
Count
:
print
(
"[+] Finished: Successfully collected all {0.count} users who @{0.config.Username} follows."
.
format
(
self
))
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