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
7cf19d7a
Commit
7cf19d7a
authored
Nov 05, 2018
by
Francesco Poldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed geo for user and tweet, updated tweet.place
parent
947c60a7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
7 deletions
+16
-7
elasticsearch/index-tweets.json
elasticsearch/index-tweets.json
+1
-0
twint/get.py
twint/get.py
+1
-1
twint/run.py
twint/run.py
+1
-1
twint/storage/elasticsearch.py
twint/storage/elasticsearch.py
+11
-3
twint/tweet.py
twint/tweet.py
+2
-2
No files found.
elasticsearch/index-tweets.json
View file @
7cf19d7a
...
...
@@ -37,6 +37,7 @@ PUT twinttweets
"quote_url"
:
{
"type"
:
"text"
},
"search"
:
{
"type"
:
"text"
},
"near"
:
{
"type"
:
"text"
},
"geo_near"
:
{
"type"
:
"geo_point"
},
"geo_tweet"
:
{
"type"
:
"geo_point"
}
}
}
...
...
twint/get.py
View file @
7cf19d7a
...
...
@@ -90,7 +90,7 @@ def ForceNewTorIdentity(config):
except
Exception
as
e
:
sys
.
stderr
.
write
(
'Error connecting to Tor control port: {}
\n
'
.
format
(
repr
(
e
)))
sys
.
stderr
.
write
(
'If you want to rotate Tor ports automatically - enable Tor control port
\n
'
)
async
def
Request
(
url
,
connector
=
None
,
params
=
[],
headers
=
[]):
#loggin.info("[<] " + str(datetime.now()) + ':: get+Request')
if
connector
:
...
...
twint/run.py
View file @
7cf19d7a
...
...
@@ -68,7 +68,7 @@ class Twint:
continue
else
:
print
(
str
(
e
))
break
break
except
Exception
as
e
:
# Sometimes Twitter says there is no data. But it's a lie.
consecutive_errors_count
+=
1
...
...
twint/storage/elasticsearch.py
View file @
7cf19d7a
...
...
@@ -17,7 +17,10 @@ class RecycleObject(object):
def
getLocation
(
place
):
location
=
geolocator
.
geocode
(
place
)
return
{
"lat"
:
location
.
latitude
,
"lon"
:
location
.
longitude
}
if
location
:
return
{
"lat"
:
location
.
latitude
,
"lon"
:
location
.
longitude
}
else
:
return
{}
def
handleIndexResponse
(
response
):
try
:
...
...
@@ -76,6 +79,7 @@ def createIndex(config, instance, **scope):
"quote_url"
:
{
"type"
:
"text"
},
"search"
:
{
"type"
:
"text"
},
"near"
:
{
"type"
:
"text"
},
"geo_near"
:
{
"type"
:
"geopoint"
},
"geo_tweet"
:
{
"type"
:
"geopoint"
}
}
}
...
...
@@ -226,7 +230,9 @@ def Tweet(Tweet, config):
}
}
if
config
.
Near
:
j_data
[
"_source"
]
.
update
({
"geo_tweet"
:
getLocation
(
config
.
Near
)})
j_data
[
"_source"
]
.
update
({
"geo_near"
:
getLocation
(
config
.
Near
)})
if
Tweet
.
place
:
j_data
[
"_source"
]
.
update
({
"geo_tweet"
:
getLocation
(
Tweet
.
place
)})
actions
.
append
(
j_data
)
es
=
Elasticsearch
(
config
.
Elasticsearch
)
...
...
@@ -290,7 +296,9 @@ def UserProfile(user, config):
}
}
if
config
.
Location
:
j_data
[
"_source"
]
.
update
({
"geo_user"
:
getLocation
(
config
.
Location
)})
_loc
=
getLocation
(
user
.
location
)
if
_loc
:
j_data
[
"_source"
]
.
update
({
"geo_user"
:
_loc
})
actions
.
append
(
j_data
)
es
=
Elasticsearch
(
config
.
Elasticsearch
)
...
...
twint/tweet.py
View file @
7cf19d7a
...
...
@@ -129,7 +129,7 @@ def Tweet(tw, location, config):
t
.
username
=
tw
[
"data-screen-name"
]
t
.
name
=
tw
[
"data-name"
]
t
.
profile_image_url
=
tw
.
find
(
"img"
,
"js-action-profile-avatar"
)
.
get
(
'src'
)
.
replace
(
"_bigger"
,
""
)
t
.
place
=
tw
.
find
(
"a"
,
"js-geo-pivot-link"
)
.
text
.
strip
()
if
tw
.
find
(
"a"
,
"js-geo-pivot-link"
)
else
None
t
.
place
=
tw
.
find
(
"a"
,
{
'class'
:
"u-textUserColor js-nav js-geo-pivot-link"
}
)
.
text
.
strip
()
if
tw
.
find
(
"a"
,
"js-geo-pivot-link"
)
else
None
t
.
timezone
=
strftime
(
"
%
Z"
,
localtime
())
for
img
in
tw
.
findAll
(
"img"
,
"Emoji Emoji--forText"
):
img
.
replaceWith
(
img
[
"alt"
])
...
...
@@ -155,4 +155,4 @@ def Tweet(tw, location, config):
t
.
in_reply_to_status_id_str
=
""
t
.
in_reply_to_user_id
=
0
t
.
in_reply_to_user_id_str
=
""
return
t
\ No newline at end of file
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