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
f12707de
Commit
f12707de
authored
May 28, 2018
by
Cody Zacharias
Committed by
GitHub
May 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.1.3 Update
parent
fbaf1c8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
50 deletions
+14
-50
twint/favorites.py
twint/favorites.py
+14
-50
No files found.
twint/favorites.py
View file @
f12707de
from
.
import
feed
,
get
,
db
,
output
import
asyncio
import
concurrent.futures
import
re
import
sys
from
.
import
feed
,
get
,
db
,
output
,
verbose
class
Favorites
:
def
__init__
(
self
,
config
):
...
...
@@ -10,62 +6,30 @@ class Favorites:
self
.
feed
=
[
-
1
]
self
.
count
=
0
self
.
config
=
config
if
self
.
config
.
Elasticsearch
:
print
(
"[+] Indexing to Elasticsearch @ "
+
str
(
self
.
config
.
Elasticsearch
))
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
)
else
:
self
.
conn
=
""
loop
=
asyncio
.
get_event_loop
()
loop
.
run_until_complete
(
self
.
main
())
self
.
conn
=
db
.
Conn
(
config
.
Database
)
self
.
config
.
Favorites
=
True
verbose
.
Elastic
(
config
)
async
def
Feed
(
self
):
url
=
await
get
.
Url
(
self
.
config
,
self
.
init
)
.
favorites
()
response
=
await
get
.
MobileRequest
(
self
.
config
,
url
)
response
=
await
get
.
RequestUrl
(
self
.
config
,
self
.
init
)
self
.
feed
=
[]
try
:
self
.
feed
,
self
.
init
=
feed
.
Favorite
(
response
)
except
:
pass
return
self
.
feed
async
def
favorites
(
self
):
await
self
.
Feed
()
try
:
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
20
)
as
executor
:
loop
=
asyncio
.
get_event_loop
()
futures
=
[]
for
tweet
in
self
.
feed
:
self
.
count
+=
1
link
=
tweet
.
find
(
"a"
)[
"href"
]
url
=
"https://twitter.com{}&lang=en"
.
format
(
link
)
futures
.
append
(
loop
.
run_in_executor
(
executor
,
await
get
.
Tweet
(
url
,
self
.
config
,
self
.
conn
)))
await
asyncio
.
gather
(
*
futures
)
self
.
feed
,
self
.
init
=
feed
.
Mobile
(
response
)
except
:
pass
async
def
main
(
self
):
if
self
.
config
.
User_id
is
not
None
:
self
.
config
.
Username
=
await
get
.
Username
(
self
.
config
)
self
.
config
.
Username
=
await
get
.
Username
(
self
.
config
.
User_id
)
while
True
:
if
len
(
self
.
feed
)
>
0
:
await
self
.
favorites
()
else
:
await
self
.
Feed
()
self
.
count
+=
await
get
.
Multi
(
self
.
feed
,
self
.
config
,
self
.
conn
)
elif
get
.
Limit
(
self
.
config
.
Limit
,
self
.
count
):
break
if
self
.
config
.
Limit
is
not
None
and
self
.
count
>=
int
(
self
.
config
.
Limit
):
else
:
break
if
self
.
config
.
Count
:
print
(
"[+] Finished: Successfully collected {0.count} Tweets that @{0.config.Username} liked."
.
format
(
self
))
verbose
.
Count
(
self
.
config
,
self
.
count
)
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