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
67daa0c1
Commit
67daa0c1
authored
Sep 28, 2018
by
Francesco Poldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update
parent
773e5c68
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
25 deletions
+30
-25
twint/get.py
twint/get.py
+7
-3
twint/output.py
twint/output.py
+3
-4
twint/run.py
twint/run.py
+20
-18
No files found.
twint/get.py
View file @
67daa0c1
...
...
@@ -112,7 +112,7 @@ async def Tweet(url, config, conn):
location
=
location
[
15
:]
.
replace
(
"
\n
"
,
" "
)[:
-
10
]
await
Tweets
(
tweet
,
location
,
config
,
conn
)
except
Exception
as
e
:
print
(
e
)
print
(
str
(
e
)
+
" [x] get.Tweet"
)
async
def
User
(
url
,
config
,
conn
):
#loggin.info("[<] " + str(datetime.now()) + ':: get+User')
...
...
@@ -121,7 +121,7 @@ async def User(url, config, conn):
soup
=
BeautifulSoup
(
response
,
"html.parser"
)
await
Users
(
soup
,
config
,
conn
)
except
Exception
as
e
:
print
(
e
)
print
(
str
(
e
)
+
" [x] get.User"
)
def
Limit
(
Limit
,
count
):
#loggin.info("[<] " + str(datetime.now()) + ':: get+Limit')
...
...
@@ -156,6 +156,10 @@ async def Multi(feed, config, conn):
await
asyncio
.
gather
(
*
futures
)
except
Exception
as
e
:
print
(
e
)
# TODO: fix error not error
# print(str(e) + " [x] get.Multi")
# will return "'NoneType' object is not callable"
# but still works
pass
return
count
twint/output.py
View file @
67daa0c1
...
...
@@ -40,10 +40,9 @@ def _output(obj, output, config, **extra):
if
config
.
Lowercase
:
if
isinstance
(
obj
,
str
):
obj
=
obj
.
lower
()
elif
str
(
type
(
obj
))
.
split
()[
0
]
==
"<class
"
:
elif
str
(
type
(
obj
))
==
"<class 'twint.user.user'>
"
:
pass
else
:
print
(
type
(
obj
))
obj
.
username
=
obj
.
username
.
lower
()
for
i
in
range
(
len
(
obj
.
mentions
)):
obj
.
mentions
[
i
]
=
obj
.
mentions
[
i
]
.
lower
()
...
...
@@ -54,7 +53,7 @@ def _output(obj, output, config, **extra):
try
:
write
.
Csv
(
obj
,
config
)
except
Exception
as
e
:
print
(
"Error: "
+
str
(
e
)
)
print
(
str
(
e
)
+
" [x] output._output"
)
elif
config
.
Store_json
:
write
.
Json
(
obj
,
config
)
else
:
...
...
@@ -77,7 +76,7 @@ def _output(obj, output, config, **extra):
print
(
output
)
pass
except
UnicodeEncodeError
:
print
(
"unicode error"
)
print
(
"unicode error
[x] output._output
"
)
async
def
Tweets
(
tw
,
location
,
config
,
conn
):
#logging.info("[<] " + str(datetime.now()) + ':: output+Tweets')
...
...
twint/run.py
View file @
67daa0c1
...
...
@@ -7,7 +7,7 @@ from .storage import db
class
Twint
:
def
__init__
(
self
,
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+__init__')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+__init__')
if
config
.
Resume
is
not
None
and
config
.
TwitterSearch
:
self
.
init
=
f
"TWEET-{config.Resume}-0"
else
:
...
...
@@ -32,7 +32,7 @@ class Twint:
self
.
config
.
Timedelta
=
(
self
.
d
.
_until
-
self
.
d
.
_since
)
.
days
async
def
Feed
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+Feed')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+Feed')
response
=
await
get
.
RequestUrl
(
self
.
config
,
self
.
init
)
if
self
.
config
.
Debug
:
print
(
response
,
file
=
open
(
"twint-last-request.log"
,
"w"
,
encoding
=
"utf-8"
))
...
...
@@ -51,10 +51,10 @@ class Twint:
elif
self
.
config
.
TwitterSearch
:
self
.
feed
,
self
.
init
=
feed
.
Json
(
response
)
except
Exception
as
e
:
print
(
e
)
print
(
str
(
e
)
+
" [x] run.Feed"
)
async
def
follow
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+follow')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+follow')
await
self
.
Feed
()
if
self
.
config
.
User_full
:
self
.
count
+=
await
get
.
Multi
(
self
.
feed
,
self
.
config
,
self
.
conn
)
...
...
@@ -65,12 +65,12 @@ class Twint:
await
output
.
Username
(
username
,
self
.
config
,
self
.
conn
)
async
def
favorite
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+favorite')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+favorite')
await
self
.
Feed
()
self
.
count
+=
await
get
.
Multi
(
self
.
feed
,
self
.
config
,
self
.
conn
)
async
def
profile
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+profile')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+profile')
await
self
.
Feed
()
if
self
.
config
.
Profile_full
:
self
.
count
+=
await
get
.
Multi
(
self
.
feed
,
self
.
config
,
self
.
conn
)
...
...
@@ -80,7 +80,7 @@ class Twint:
await
output
.
Tweets
(
tweet
,
""
,
self
.
config
,
self
.
conn
)
async
def
tweets
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+tweets')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+tweets')
await
self
.
Feed
()
if
self
.
config
.
Location
:
self
.
count
+=
await
get
.
Multi
(
self
.
feed
,
self
.
config
,
self
.
conn
)
...
...
@@ -90,7 +90,7 @@ class Twint:
await
output
.
Tweets
(
tweet
,
""
,
self
.
config
,
self
.
conn
)
async
def
main
(
self
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+main')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+main')
if
self
.
config
.
User_id
is
not
None
:
self
.
config
.
Username
=
await
get
.
Username
(
self
.
config
.
User_id
)
...
...
@@ -105,7 +105,7 @@ class Twint:
self
.
d
.
_until
=
self
.
d
.
_until
-
_days
self
.
feed
=
[
-
1
]
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+main+CallingGetLimit1')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+main+CallingGetLimit1')
if
get
.
Limit
(
self
.
config
.
Limit
,
self
.
count
):
self
.
d
.
_until
=
self
.
d
.
_until
-
_days
self
.
feed
=
[
-
1
]
...
...
@@ -123,7 +123,7 @@ class Twint:
else
:
break
#loggin.info("[<] " + str(datetime.now()) + ':: run+Twint+main+CallingGetLimit2')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Twint+main+CallingGetLimit2')
if
get
.
Limit
(
self
.
config
.
Limit
,
self
.
count
):
break
...
...
@@ -131,16 +131,16 @@ class Twint:
verbose
.
Count
(
self
.
count
,
self
.
config
)
def
run
(
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+run')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+run')
get_event_loop
()
.
run_until_complete
(
Twint
(
config
)
.
main
())
def
Favorites
(
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Favorites')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Favorites')
config
.
Favorites
=
True
run
(
config
)
def
Followers
(
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Followers')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Followers')
output
.
clean_follow_list
()
config
.
Followers
=
True
config
.
Following
=
False
...
...
@@ -149,10 +149,11 @@ def Followers(config):
storage
.
panda
.
_autoget
(
"followers"
)
if
config
.
User_full
:
storage
.
panda
.
_autoget
(
"user"
)
if
config
.
Pandas
:
storage
.
panda
.
clean
()
def
Following
(
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Following')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Following')
output
.
clean_follow_list
()
config
.
Following
=
True
config
.
Followers
=
False
...
...
@@ -161,15 +162,16 @@ def Following(config):
storage
.
panda
.
_autoget
(
"following"
)
if
config
.
User_full
:
storage
.
panda
.
_autoget
(
"user"
)
if
config
.
Pandas
:
storage
.
panda
.
clean
()
def
Profile
(
config
):
config
.
Profile
=
True
#loggin.info("[<] " + str(datetime.now()) + ':: run+Profile')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Profile')
run
(
config
)
def
Search
(
config
):
#loggin.info("[<] " + str(datetime.now()) + ':: run+Search')
#loggin
g
.info("[<] " + str(datetime.now()) + ':: run+Search')
config
.
TwitterSearch
=
True
config
.
Following
=
False
config
.
Followers
=
False
...
...
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