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
12793ac5
Commit
12793ac5
authored
Feb 17, 2022
by
minamotorin
Committed by
GitHub
Feb 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cannot connect to host twitter.com:443 ssl:True
Related to aiohttp.client_exceptions.ClientConnectorError
parent
afbea153
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
twint/get.py
twint/get.py
+24
-6
No files found.
twint/get.py
View file @
12793ac5
...
...
@@ -11,6 +11,7 @@ import random
from
json
import
loads
,
dumps
from
aiohttp_socks
import
ProxyConnector
,
ProxyType
from
urllib.parse
import
quote
import
time
from
.
import
url
from
.output
import
Tweets
,
Users
...
...
@@ -163,12 +164,29 @@ async def Request(_url, connector=None, params=None, headers=None):
async
def
Response
(
session
,
_url
,
params
=
None
):
logme
.
debug
(
__name__
+
':Response'
)
with
timeout
(
120
):
async
with
session
.
get
(
_url
,
ssl
=
True
,
params
=
params
,
proxy
=
httpproxy
)
as
response
:
resp
=
await
response
.
text
()
if
response
.
status
==
429
:
# 429 implies Too many requests i.e. Rate Limit Exceeded
raise
TokenExpiryException
(
loads
(
resp
)[
'errors'
][
0
][
'message'
])
return
resp
retries
=
5
wait
=
10
# No basis, maybe work with 0
for
attempt
in
range
(
retries
+
1
):
try
:
with
timeout
(
120
):
async
with
session
.
get
(
_url
,
ssl
=
True
,
params
=
params
,
proxy
=
httpproxy
)
as
response
:
resp
=
await
response
.
text
()
if
response
.
status
==
429
:
# 429 implies Too many requests i.e. Rate Limit Exceeded
raise
TokenExpiryException
(
loads
(
resp
)[
'errors'
][
0
][
'message'
])
return
resp
except
aiohttp
.
client_exceptions
.
ClientConnectorError
as
exc
:
if
attempt
<
retries
:
retrying
=
', retrying'
level
=
logme
.
WARNING
else
:
retrying
=
''
level
=
logme
.
ERROR
logme
.
log
(
level
,
f
'Error retrieving {_url}: {exc!r}{retrying}'
)
if
attempt
<
retries
:
time
.
sleep
(
wait
)
else
:
logme
.
fatal
(
f
'{retries + 1} requests to {_url} failed, giving up.'
)
raise
TokenExpiryException
(
f
'{exc!r}'
)
async
def
RandomUserAgent
(
wa
=
None
):
...
...
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