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
eb8ceda6
Commit
eb8ceda6
authored
May 26, 2018
by
Cody Zacharias
Committed by
GitHub
May 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update get.py
parent
3fce83dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
86 deletions
+108
-86
twint/get.py
twint/get.py
+108
-86
No files found.
twint/get.py
View file @
eb8ceda6
...
@@ -5,94 +5,116 @@ import async_timeout
...
@@ -5,94 +5,116 @@ import async_timeout
import
asyncio
import
asyncio
class
Url
:
class
Url
:
def
__init__
(
self
,
config
,
init
):
def
__init__
(
self
,
config
,
init
):
self
.
config
=
config
self
.
config
=
config
self
.
init
=
init
self
.
init
=
init
async
def
favorites
(
self
):
async
def
favorites
(
self
):
if
self
.
init
==
-
1
:
url
=
"https://mobile.twitter.com/{0.Username}/favorites?lang=en"
.
format
(
self
.
config
)
url
=
"https://mobile.twitter.com/{0.Username}/favorites?lang=en"
.
format
(
self
.
config
)
else
:
if
self
.
init
!=
-
1
:
url
=
"https://mobile.twitter.com/{0.Username}/favorites?max_id={1.init}&lang=en"
.
format
(
self
.
config
,
self
)
url
+=
"&max_id={0.init}"
.
format
(
self
)
return
url
return
url
async
def
followers
(
self
):
if
self
.
init
==
-
1
:
async
def
followers
(
self
):
url
=
"https://mobile.twitter.com/{0.Username}/followers?lang=en"
.
format
(
self
.
config
)
url
=
"https://mobile.twitter.com/{0.Username}/followers?lang=en"
.
format
(
self
.
config
)
else
:
url
=
"https://mobile.twitter.com/{0.Username}/followers?cursor={1.init}&lang=en"
.
format
(
self
.
config
,
self
)
if
self
.
init
!=
-
1
:
return
url
url
+=
"&cursor={0.init}"
.
format
(
self
)
async
def
following
(
self
):
return
url
if
self
.
init
==
-
1
:
url
=
"https://mobile.twitter.com/{0.Username}/following?lang=en"
.
format
(
self
.
config
)
async
def
following
(
self
):
else
:
url
=
"https://mobile.twitter.com/{0.Username}/following?lang=en"
.
format
(
self
.
config
)
url
=
"https://mobile.twitter.com/{0.Username}/following?cursor={1.init}&lang=en"
.
format
(
self
.
config
,
self
)
return
url
if
self
.
init
!=
-
1
:
url
+=
"&cursor={0.init}"
.
format
(
self
)
async
def
search
(
self
):
if
self
.
init
==
-
1
:
return
url
url
=
"https://twitter.com/search?f=tweets&vertical=default&lang=en&q="
else
:
async
def
profile
(
self
):
url
=
"https://twitter.com/i/search/timeline?f=tweets&vertical=default"
url
=
"https://twitter.com/i/profiles/show/{0.Username}/timeline/tweets"
.
format
(
self
.
config
)
url
+=
"&lang=en&include_available_features=1&include_entities=1&reset_"
url
+=
"?include_available_features=1&lang=en&include_entities=1&include"
url
+=
"error_state=false&src=typd&max_position={0.init}&q="
.
format
(
self
)
url
+=
"_new_items_bar=true"
if
self
.
config
.
Lang
!=
None
:
if
self
.
init
!=
-
1
:
url
=
url
.
replace
(
"lang=en"
,
"l={0.Lang}&lang=en"
.
format
(
self
.
config
))
url
+=
"&max_position={0.init}"
.
format
(
self
)
if
self
.
config
.
Username
!=
None
:
url
+=
"from
%3
A{0.Username}"
.
format
(
self
.
config
)
return
url
if
self
.
config
.
Geo
!=
None
:
self
.
config
.
Geo
=
self
.
config
.
Geo
.
replace
(
" "
,
""
)
async
def
search
(
self
):
url
+=
"geocode
%3
A{0.Geo}"
.
format
(
self
.
config
)
url
=
"https://twitter.com/i/search/timeline?f=tweets&vertical=default"
if
self
.
config
.
Search
!=
None
:
url
+=
"&lang=en&include_available_features=1&include_entities=1&reset_"
self
.
config
.
Search
=
self
.
config
.
Search
.
replace
(
" "
,
"
%20
"
)
url
+=
"error_state=false&src=typd&max_position={0.init}&q="
.
format
(
self
)
self
.
config
.
Search
=
self
.
config
.
Search
.
replace
(
"#"
,
"
%23
"
)
url
+=
"
%20
{0.Search}"
.
format
(
self
.
config
)
if
self
.
config
.
Lang
!=
None
:
if
self
.
config
.
Year
!=
None
:
url
=
url
.
replace
(
"lang=en"
,
"l={0.Lang}&lang=en"
.
format
(
self
.
config
))
url
+=
"
%20
until
%3
A{0.Year}-1-1"
.
format
(
self
.
config
)
if
self
.
config
.
Username
!=
None
:
if
self
.
config
.
Since
!=
None
:
url
+=
"from
%3
A{0.Username}"
.
format
(
self
.
config
)
url
+=
"
%20
since
%3
A{0.Since}"
.
format
(
self
.
config
)
if
self
.
config
.
Geo
!=
None
:
if
self
.
config
.
Until
!=
None
:
self
.
config
.
Geo
=
self
.
config
.
Geo
.
replace
(
" "
,
""
)
url
+=
"
%20
until
%3
A{0.Until}"
.
format
(
self
.
config
)
url
+=
"geocode
%3
A{0.Geo}"
.
format
(
self
.
config
)
if
self
.
config
.
Fruit
:
if
self
.
config
.
Search
!=
None
:
url
+=
"
%20
myspace.com
%20
OR
%20
last.fm
%20
OR"
self
.
config
.
Search
=
self
.
config
.
Search
.
replace
(
" "
,
"
%20
"
)
url
+=
"
%20
mail
%20
OR
%20
email
%20
OR
%20
gmail
%20
OR
%20
e-mail"
self
.
config
.
Search
=
self
.
config
.
Search
.
replace
(
"#"
,
"
%23
"
)
url
+=
"
%20
OR
%20
phone
%20
OR
%20
call
%20
me
%20
OR
%20
text
%20
me"
url
+=
"
%20
{0.Search}"
.
format
(
self
.
config
)
url
+=
"
%20
OR
%20
keybase"
if
self
.
config
.
Year
!=
None
:
if
self
.
config
.
Verified
:
url
+=
"
%20
until
%3
A{0.Year}-1-1"
.
format
(
self
.
config
)
url
+=
"
%20
filter
%3
Averfied"
if
self
.
config
.
Since
!=
None
:
if
self
.
config
.
To
:
url
+=
"
%20
since
%3
A{0.Since}"
.
format
(
self
.
config
)
url
+=
"
%20
to
%3
A{0.To}"
.
format
(
self
.
config
)
if
self
.
config
.
Until
!=
None
:
if
self
.
config
.
All
:
url
+=
"
%20
until
%3
A{0.Until}"
.
format
(
self
.
config
)
url
+=
"
%20
to
%3
A{0.All}
%20
OR
%20
from
%3
A{0.All}
%20
OR
%20
@{0.All}"
.
format
(
self
.
config
)
if
self
.
config
.
Fruit
:
if
self
.
config
.
Near
:
url
+=
"
%20
myspace.com
%20
OR
%20
last.fm
%20
OR"
self
.
config
.
Near
=
self
.
config
.
Near
.
replace
(
" "
,
"
%20
"
)
url
+=
"
%20
mail
%20
OR
%20
email
%20
OR
%20
gmail
%20
OR
%20
e-mail"
self
.
config
.
Near
=
self
.
config
.
Near
.
replace
(
","
,
"
%2
C"
)
url
+=
"
%20
OR
%20
phone
%20
OR
%20
call
%20
me
%20
OR
%20
text
%20
me"
url
+=
"
%20
near
%3
A{0.Near}"
.
format
(
self
.
config
)
url
+=
"
%20
OR
%20
keybase"
return
url
if
self
.
config
.
Verified
:
url
+=
"
%20
filter
%3
Averified"
if
self
.
config
.
To
:
url
+=
"
%20
to
%3
A{0.To}"
.
format
(
self
.
config
)
if
self
.
config
.
All
:
url
+=
"
%20
to
%3
A{0.All}
%20
OR
%20
from
%3
A{0.All}
%20
OR
%20
@{0.All}"
.
format
(
self
.
config
)
if
self
.
config
.
Near
:
self
.
config
.
Near
=
self
.
config
.
Near
.
replace
(
" "
,
"
%20
"
)
self
.
config
.
Near
=
self
.
config
.
Near
.
replace
(
","
,
"
%2
C"
)
url
+=
"
%20
near
%3
A{0.Near}"
.
format
(
self
.
config
)
return
url
async
def
MobileRequest
(
config
,
url
):
ua
=
{
'User-Agent'
:
'Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/0.8.12'
}
connect
=
aiohttp
.
TCPConnector
(
verify_ssl
=
False
)
async
with
aiohttp
.
ClientSession
(
headers
=
ua
,
connector
=
connect
)
as
session
:
return
await
Response
(
session
,
url
)
async
def
Request
(
config
,
url
):
connect
=
aiohttp
.
TCPConnector
(
verify_ssl
=
False
)
async
with
aiohttp
.
ClientSession
(
connector
=
connect
)
as
session
:
return
await
Response
(
session
,
url
)
async
def
Response
(
session
,
url
):
async
def
Response
(
session
,
url
):
with
async_timeout
.
timeout
(
30
):
with
async_timeout
.
timeout
(
30
):
async
with
session
.
get
(
url
)
as
response
:
async
with
session
.
get
(
url
)
as
response
:
return
await
response
.
text
()
return
await
response
.
text
()
async
def
Username
(
config
):
url
=
"https://twitter.com/intent/user?user_id={}&lang=en"
.
format
(
config
.
User_id
)
r
=
Request
(
config
,
url
)
soup
=
BeautifulSoup
(
r
,
"html.parser"
)
async
def
Username
(
userid
):
return
soup
.
find
(
"a"
,
"fn url alternate-context"
)[
"href"
]
.
replace
(
"/"
,
""
)
connect
=
aiohttp
.
TCPConnector
(
verify_ssl
=
False
)
async
with
aiohttp
.
ClientSession
(
connector
=
connect
)
as
session
:
r
=
await
Response
(
session
,
"https://twitter.com/intent/user?user_id={}&lang=en"
.
format
(
userid
))
soup
=
BeautifulSoup
(
r
,
"html.parser"
)
return
soup
.
find
(
"a"
,
"fn url alternate-context"
)[
"href"
]
.
replace
(
"/"
,
""
)
async
def
Tweet
(
url
,
config
,
conn
):
async
def
Tweet
(
url
,
config
,
conn
):
try
:
try
:
connect
=
aiohttp
.
TCPConnector
(
verify_ssl
=
False
)
response
=
await
Request
(
config
,
url
)
async
with
aiohttp
.
ClientSession
(
connector
=
connect
)
as
session
:
soup
=
BeautifulSoup
(
response
,
"html.parser"
)
response
=
await
Response
(
session
,
url
)
tweet
=
soup
.
find
(
"div"
,
"permalink-inner permalink-tweet-container"
)
soup
=
BeautifulSoup
(
response
,
"html.parser"
)
location
=
soup
.
find
(
"span"
,
"ProfileHeaderCard-locationText u-dir"
)
.
text
tweet
=
soup
.
find
(
"div"
,
"permalink-inner permalink-tweet-container
"
)
location
=
location
.
replace
(
"
\n
"
,
"
"
)
# Experimental
location
=
location
.
replace
(
" "
,
""
)
location
=
soup
.
find
(
"span"
,
"ProfileHeaderCard-locationText u-dir"
)
.
text
.
replace
(
"
\n
"
,
""
)
.
replace
(
" "
,
""
)
.
replace
(
","
,
", "
)
location
=
location
.
replace
(
","
,
", "
)
await
output
.
Tweets
(
tweet
,
location
,
config
,
conn
)
await
output
.
Tweets
(
tweet
,
location
,
config
,
conn
)
except
:
except
:
pass
pass
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