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
445ef7bb
Commit
445ef7bb
authored
Mar 29, 2018
by
Cody Zacharias
Committed by
GitHub
Mar 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #49 from prabod/master
Replace all emoticons with their title, to be included in the tweet text
parents
393f2895
190625c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
tweep.py
tweep.py
+10
-0
No files found.
tweep.py
View file @
445ef7bb
...
@@ -127,6 +127,9 @@ async def outTweet(tweet):
...
@@ -127,6 +127,9 @@ async def outTweet(tweet):
# The @ in the username annoys me.
# The @ in the username annoys me.
username
=
tweet
.
find
(
"span"
,
"username"
)
.
text
.
replace
(
"@"
,
""
)
username
=
tweet
.
find
(
"span"
,
"username"
)
.
text
.
replace
(
"@"
,
""
)
timezone
=
strftime
(
"
%
Z"
,
gmtime
())
timezone
=
strftime
(
"
%
Z"
,
gmtime
())
# Replace all emoticons with their title, to be included in the tweet text
for
img
in
tweet
.
findAll
(
"img"
,
"Emoji Emoji--forText"
):
img
.
replaceWith
(
"<
%
s>"
%
img
[
'aria-label'
])
# The context of the Tweet compressed into a single line.
# The context of the Tweet compressed into a single line.
text
=
tweet
.
find
(
"p"
,
"tweet-text"
)
.
text
.
replace
(
"
\n
"
,
""
)
.
replace
(
"http"
,
" http"
)
.
replace
(
"pic.twitter"
,
" pic.twitter"
)
text
=
tweet
.
find
(
"p"
,
"tweet-text"
)
.
text
.
replace
(
"
\n
"
,
""
)
.
replace
(
"http"
,
" http"
)
.
replace
(
"pic.twitter"
,
" pic.twitter"
)
# Regex for gathering hashtags
# Regex for gathering hashtags
...
@@ -201,6 +204,12 @@ async def outTweet(tweet):
...
@@ -201,6 +204,12 @@ async def outTweet(tweet):
with
open
(
arg
.
o
,
"a"
,
newline
=
''
,
encoding
=
"utf-8"
)
as
csv_file
:
with
open
(
arg
.
o
,
"a"
,
newline
=
''
,
encoding
=
"utf-8"
)
as
csv_file
:
writer
=
csv
.
writer
(
csv_file
,
delimiter
=
"|"
)
writer
=
csv
.
writer
(
csv_file
,
delimiter
=
"|"
)
writer
.
writerow
(
dat
)
writer
.
writerow
(
dat
)
elif
arg
.
json
:
# Write all variables scraped to JSON
dat
=
{
"id"
:
tweetid
,
"date"
:
date
,
"time"
:
time
,
"timezone"
:
timezone
,
"username"
:
username
,
"content"
:
text
,
"replies"
:
replies
,
"retweets"
:
retweets
,
"likes"
:
likes
,
"hashtags"
:
hashtags
}
with
open
(
arg
.
o
,
"a"
,
newline
=
''
,
encoding
=
"utf-8"
)
as
json_file
:
json
.
dump
(
dat
,
json_file
)
json_file
.
write
(
'
\n
'
)
else
:
else
:
# Writes or appends to a file.
# Writes or appends to a file.
print
(
output
,
file
=
open
(
arg
.
o
,
"a"
,
encoding
=
"utf-8"
))
print
(
output
,
file
=
open
(
arg
.
o
,
"a"
,
encoding
=
"utf-8"
))
...
@@ -306,6 +315,7 @@ if __name__ == "__main__":
...
@@ -306,6 +315,7 @@ if __name__ == "__main__":
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
(
"--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
(
"--csv"
,
help
=
"Write as .csv 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
(
"--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
(
"--limit"
,
help
=
"Number of Tweets to pull (Increments of 20)."
)
...
...
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