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
25a85ef0
Commit
25a85ef0
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
ab8000da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
18 deletions
+75
-18
twint/tweet.py
twint/tweet.py
+75
-18
No files found.
twint/tweet.py
View file @
25a85ef0
class
Tweet
:
id
=
""
datetime
=
""
datestamp
=
""
timestamp
=
""
timezone
=
""
user_id
=
""
username
=
""
mentions
=
""
tweet
=
""
replies
=
"0"
likes
=
"0"
retweets
=
"0"
hashtags
=
""
location
=
""
link
=
""
is_retweet
=
False
user_rt
=
""
# User that retweeted
from
time
import
strftime
,
localtime
import
re
class
tweet
:
pass
def
getMentions
(
tw
):
try
:
mentions
=
tw
.
find
(
"div"
,
"js-original-tweet"
)[
"data-mentions"
]
.
split
(
" "
)
except
:
mentions
=
""
return
mentions
def
getText
(
tw
):
text
=
tw
.
find
(
"p"
,
"tweet-text"
)
.
text
text
=
text
.
replace
(
"
\n
"
,
""
)
text
=
text
.
replace
(
"http"
,
" http"
)
text
=
text
.
replace
(
"pic.twitter"
,
" pic.twitter"
)
return
text
def
getTweet
(
tw
,
mentions
):
try
:
text
=
getText
(
tw
)
for
i
in
range
(
len
(
mentions
)):
mention
=
"@{}"
.
format
(
mentions
[
i
])
if
mention
not
in
text
:
text
=
"{} {}"
.
format
(
mention
,
text
)
except
:
text
=
getText
(
tw
)
return
text
def
getHashtags
(
text
):
return
re
.
findall
(
r'(?i)\#\w+'
,
text
,
flags
=
re
.
UNICODE
)
def
getStat
(
tw
,
_type
):
st
=
"ProfileTweet-action--{} u-hiddenVisually"
.
format
(
_type
)
return
tw
.
find
(
"span"
,
st
)
.
find
(
"span"
)[
"data-tweet-stat-count"
]
def
getRetweet
(
profile
,
username
,
user
):
if
profile
and
username
.
lower
()
!=
user
:
return
True
def
getUser_rt
(
profile
,
username
,
user
):
if
getRetweet
(
profile
,
username
,
user
):
user_rt
=
user
else
:
user_rt
=
"None"
return
user_rt
def
Tweet
(
tw
,
location
,
config
):
t
=
tweet
()
t
.
id
=
tw
.
find
(
"div"
)[
"data-item-id"
]
t
.
datetime
=
int
(
tw
.
find
(
"span"
,
"_timestamp"
)[
"data-time"
])
t
.
datestamp
=
strftime
(
"
%
Y-
%
m-
%
d"
,
localtime
(
t
.
datetime
))
t
.
timestamp
=
strftime
(
"
%
H:
%
M:
%
S"
,
localtime
(
t
.
datetime
))
t
.
user_id
=
tw
.
find
(
"a"
,
"account-group js-account-group js-action-profile js-user-profile-link js-nav"
)[
"data-user-id"
]
t
.
username
=
tw
.
find
(
"span"
,
"username"
)
.
text
.
replace
(
"@"
,
""
)
t
.
timezone
=
strftime
(
"
%
Z"
,
localtime
())
for
img
in
tw
.
findAll
(
"img"
,
"Emoji Emoji--forText"
):
img
.
replaceWith
(
"<{}>"
.
format
(
img
[
'aria-label'
]))
t
.
mentions
=
getMentions
(
tw
)
t
.
tweet
=
getTweet
(
tw
,
t
.
mentions
)
t
.
location
=
location
t
.
hashtags
=
getHashtags
(
t
.
tweet
)
t
.
replies
=
getStat
(
tw
,
"reply"
)
t
.
retweets
=
getStat
(
tw
,
"retweet"
)
t
.
likes
=
getStat
(
tw
,
"favorite"
)
t
.
link
=
"https://twitter.com/{0.username}/status/{0.id}"
.
format
(
t
)
t
.
retweet
=
getRetweet
(
config
.
Profile
,
t
.
username
,
config
.
Username
)
t
.
user_rt
=
getUser_rt
(
config
.
Profile
,
t
.
username
,
config
.
Username
)
return
t
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