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
343bd2bf
Commit
343bd2bf
authored
Nov 02, 2018
by
Francesco Poldi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added geopoint
Now we will map tweets when scraping with --near
parent
761afcf1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
elasticsearch/index-tweets.json
elasticsearch/index-tweets.json
+2
-1
requirements.txt
requirements.txt
+2
-1
twint/storage/elasticsearch.py
twint/storage/elasticsearch.py
+13
-1
No files found.
elasticsearch/index-tweets.json
View file @
343bd2bf
...
...
@@ -36,7 +36,8 @@ PUT twinttweets
"quote_id_str"
:
{
"type"
:
"text"
},
"quote_url"
:
{
"type"
:
"text"
},
"search"
:
{
"type"
:
"text"
},
"near"
:
{
"type"
:
"text"
}
"near"
:
{
"type"
:
"text"
},
"geo_point"
:
{
"type"
:
"geopoint"
}
}
}
}
...
...
requirements.txt
View file @
343bd2bf
...
...
@@ -6,4 +6,5 @@ elasticsearch
pysocks
pandas
aiohttp_socks
schedule
\ No newline at end of file
schedule
geopy
twint/storage/elasticsearch.py
View file @
343bd2bf
## TODO - Fix Weekday situation
from
elasticsearch
import
Elasticsearch
,
helpers
from
geopy.geocoders
import
Nominatim
from
time
import
strftime
,
localtime
import
contextlib
import
sys
...
...
@@ -8,10 +9,18 @@ _index_tweet_status = False
_index_follow_status
=
False
_index_user_status
=
False
geolocator
=
Nominatim
(
user_agent
=
"twint-1.2"
)
class
RecycleObject
(
object
):
def
write
(
self
,
junk
):
pass
def
flush
(
self
):
pass
def
getLocation
(
place
):
location
=
geolocator
.
geocode
(
place
)
if
location
:
return
{
"lat"
:
location
.
latitude
,
"lon"
:
location
.
longitude
}
return
{}
def
handleIndexResponse
(
response
):
try
:
if
response
[
"status"
]
==
400
:
...
...
@@ -171,6 +180,8 @@ def Tweet(Tweet, config):
}
day
=
weekdays
[
strftime
(
"
%
A"
,
localtime
(
Tweet
.
datetime
))]
location
=
getLocation
(
config
.
Near
)
actions
=
[]
dt
=
f
"{Tweet.datestamp} {Tweet.timestamp}"
...
...
@@ -213,7 +224,8 @@ def Tweet(Tweet, config):
"quote_id_str"
:
Tweet
.
quote_id_str
,
"quote_url"
:
Tweet
.
quote_url
,
"search"
:
str
(
config
.
Search
),
"near"
:
config
.
Near
"near"
:
config
.
Near
,
"geo_point"
:
location
}
}
actions
.
append
(
j_data
)
...
...
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