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
955aa70b
Commit
955aa70b
authored
Apr 14, 2018
by
Cody Zacharias
Committed by
GitHub
Apr 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Begin rolling out debuging
parent
45834804
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
twint.py
twint.py
+26
-10
No files found.
twint.py
View file @
955aa70b
...
@@ -216,6 +216,15 @@ def cont(response):
...
@@ -216,6 +216,15 @@ def cont(response):
return
feed
,
"-"
.
join
(
split
)
return
feed
,
"-"
.
join
(
split
)
def
err
(
e
,
func
):
now
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
msg
=
"[{}] {} - {}"
.
format
(
now
,
func
,
e
)
if
arg
.
o
:
print
(
msg
,
file
=
open
(
arg
.
o
,
"a"
,
encoding
=
"utf-8"
))
print
(
msg
,
file
=
open
(
"twint_debug.log"
,
"a"
,
encoding
=
"utf-8"
))
print
(
msg
)
def
follow
(
response
):
def
follow
(
response
):
'''
'''
Response and parsing of a user's followers or following list.
Response and parsing of a user's followers or following list.
...
@@ -226,8 +235,9 @@ def follow(response):
...
@@ -226,8 +235,9 @@ def follow(response):
# Try & Except neccessary for collecting the last feed.
# Try & Except neccessary for collecting the last feed.
try
:
try
:
cursor
=
re
.
findall
(
r'cursor=(.*?)">'
,
str
(
cursor
))[
0
]
cursor
=
re
.
findall
(
r'cursor=(.*?)">'
,
str
(
cursor
))[
0
]
except
:
except
Exception
as
e
:
pass
if
arg
.
debug
:
err
(
e
,
"follow()"
)
return
followers
,
cursor
return
followers
,
cursor
...
@@ -241,8 +251,10 @@ def favorite(response):
...
@@ -241,8 +251,10 @@ def favorite(response):
# Try & Except neccessary for collecting the last feed.
# Try & Except neccessary for collecting the last feed.
try
:
try
:
max_id
=
re
.
findall
(
r'max_id=(.*?)">'
,
str
(
max_id
))[
0
]
max_id
=
re
.
findall
(
r'max_id=(.*?)">'
,
str
(
max_id
))[
0
]
except
:
except
Exception
as
e
:
pass
if
arg
.
debug
:
err
(
e
,
"favorite()"
)
return
tweets
,
max_id
return
tweets
,
max_id
async
def
getfeed
(
init
):
async
def
getfeed
(
init
):
...
@@ -335,8 +347,9 @@ async def outTweet(tweet):
...
@@ -335,8 +347,9 @@ async def outTweet(tweet):
mention
=
"@{}"
.
format
(
mentions
[
i
])
mention
=
"@{}"
.
format
(
mentions
[
i
])
if
mention
not
in
text
:
if
mention
not
in
text
:
text
=
"{} {}"
.
format
(
mention
,
text
)
text
=
"{} {}"
.
format
(
mention
,
text
)
except
:
except
Exception
as
e
:
pass
if
arg
.
debug
:
err
(
e
,
"outTweet()"
)
# Preparing storage
# Preparing storage
...
@@ -530,8 +543,9 @@ async def getTweet(url):
...
@@ -530,8 +543,9 @@ async def getTweet(url):
print
(
await
outTweet
(
tweet
),
end
=
"."
,
flush
=
True
)
print
(
await
outTweet
(
tweet
),
end
=
"."
,
flush
=
True
)
else
:
else
:
print
(
await
outTweet
(
tweet
))
print
(
await
outTweet
(
tweet
))
except
:
except
Exception
as
e
:
pass
if
arg
.
debug
:
err
(
e
,
"getTweet()"
)
async
def
getFavorites
(
init
):
async
def
getFavorites
(
init
):
'''
'''
...
@@ -552,8 +566,9 @@ async def getFavorites(init):
...
@@ -552,8 +566,9 @@ async def getFavorites(init):
futures
.
append
(
loop
.
run_in_executor
(
executor
,
await
getTweet
(
url
)))
futures
.
append
(
loop
.
run_in_executor
(
executor
,
await
getTweet
(
url
)))
await
asyncio
.
gather
(
*
futures
)
await
asyncio
.
gather
(
*
futures
)
except
:
except
Exception
as
e
:
pass
if
arg
.
debug
:
err
(
e
,
"getFavorites()"
)
return
tweets
,
init
,
count
return
tweets
,
init
,
count
...
@@ -747,6 +762,7 @@ if __name__ == "__main__":
...
@@ -747,6 +762,7 @@ if __name__ == "__main__":
ap
.
add_argument
(
"--followers"
,
help
=
"Scrape a person's followers"
,
action
=
"store_true"
)
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
(
"--following"
,
help
=
"Scrape who a person follows."
,
action
=
"store_true"
)
ap
.
add_argument
(
"--favorites"
,
help
=
"Scrape Tweets a user has liked."
,
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"
)
arg
=
ap
.
parse_args
()
arg
=
ap
.
parse_args
()
check
()
check
()
...
...
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