How to prevent Python aiohttp ClientOSError?How to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?
How Total raw is calculated for Science pack 2?
Using font to highlight a god's speech in dialogue
Mathematica not simplifying rational powers in complex expressions
How could reincarnation magic be limited to prevent overuse?
Why do modes sound so different, although they are basically the same as a mode of another scale?
Why KVM VPS is slower then OPENVZ
How to create a template with variable number of type parameters?
What is the definition of Product
What is the converted mana cost of land cards?
Why is k-means used for non normally distributed data?
If the government illegally doesn't ask for article 50 extension, can parliament do it instead?
What laws protect minority share holders from having their share rights changed by special resolution?
Divide Numbers by 0
Why are my split equations aligned to right by default?
Is the mnemonic in Winter's Tale real?
What is the significance of 104%
Displaying Time in HH:MM Format
How did Gollum know Sauron was gathering the Haradrim to make war?
How to align values in table according to the pm and point?
Why would a Intel 8080 chip be destroyed if +12 V is connected before -5 V?
What happens if you just start drawing from the Deck of Many Things without declaring any number of cards?
Does the Scrying spell require you to have a clear path to the target in order to work?
How to have the "Restore Missing Files" function from Nautilus without installing Nautilus?
Why does this regexpatch command only work once, not twice?
How to prevent Python aiohttp ClientOSError?
How to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm currently using a library called Twint that is used for collecting Tweets. I wrote a short script to collect the Tweets from a CSV of usernames but the connection got terminated while the script was running. Here's what I wrote:
import twint
import pandas as pd
def twint_scrape(username, output, since='2017-05-10', until='2019-01-07'):
c = twint.Config()
c.Username = username
print("Scraping Tweets for ".format(c.Username))
c.Since = since
print("Starting date: ".format(c.Since))
c.Until = until
print("End date: ".format(c.Until))
c.Store_csv = True
c.Hide_output = True
c.Output = output
twint.run.Search(c)
return None
names_accounts = pd.read_csv('./names_accounts.csv')
usernames = names_accounts['Account']
for username in usernames:
print("Current username: ".format(username))
twint_scrape(username, username)
And this is the error message that I get:
Traceback (most recent call last):
File "./twitter_scraper.py", line 29, in <module>
twint_scrape(username, username)
File "./twitter_scraper.py", line 20, in twint_scrape
twint.run.Search(c)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 201, in Search
run(config)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File "C:UsersseantAnaconda3libasynciobase_events.py", line 573, in run_until_complete
return future.result()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 121, in main
await self.tweets()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 97, in tweets
await self.Feed()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 40, in Feed
response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 58, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=headers)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 89, in Request
return await Response(session, url, params)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 94, in Response
async with session.get(url, ssl=False, params=params) as response:
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 1005, in __aenter__
self._resp = await self._coro
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 497, in _request
await resp.start(conn)
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "C:UsersseantAnaconda3libsite-packagesaiohttpstreams.py", line 588, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054] 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다
The Korean in the last line is basically saying that the connection has been terminated by a remote host.
Is there anyway that I can keep the connection alive while keeping my script running? Any feedback would be greatly appreciated. Thanks!
python aiohttp
add a comment |
I'm currently using a library called Twint that is used for collecting Tweets. I wrote a short script to collect the Tweets from a CSV of usernames but the connection got terminated while the script was running. Here's what I wrote:
import twint
import pandas as pd
def twint_scrape(username, output, since='2017-05-10', until='2019-01-07'):
c = twint.Config()
c.Username = username
print("Scraping Tweets for ".format(c.Username))
c.Since = since
print("Starting date: ".format(c.Since))
c.Until = until
print("End date: ".format(c.Until))
c.Store_csv = True
c.Hide_output = True
c.Output = output
twint.run.Search(c)
return None
names_accounts = pd.read_csv('./names_accounts.csv')
usernames = names_accounts['Account']
for username in usernames:
print("Current username: ".format(username))
twint_scrape(username, username)
And this is the error message that I get:
Traceback (most recent call last):
File "./twitter_scraper.py", line 29, in <module>
twint_scrape(username, username)
File "./twitter_scraper.py", line 20, in twint_scrape
twint.run.Search(c)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 201, in Search
run(config)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File "C:UsersseantAnaconda3libasynciobase_events.py", line 573, in run_until_complete
return future.result()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 121, in main
await self.tweets()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 97, in tweets
await self.Feed()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 40, in Feed
response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 58, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=headers)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 89, in Request
return await Response(session, url, params)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 94, in Response
async with session.get(url, ssl=False, params=params) as response:
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 1005, in __aenter__
self._resp = await self._coro
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 497, in _request
await resp.start(conn)
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "C:UsersseantAnaconda3libsite-packagesaiohttpstreams.py", line 588, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054] 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다
The Korean in the last line is basically saying that the connection has been terminated by a remote host.
Is there anyway that I can keep the connection alive while keeping my script running? Any feedback would be greatly appreciated. Thanks!
python aiohttp
add a comment |
I'm currently using a library called Twint that is used for collecting Tweets. I wrote a short script to collect the Tweets from a CSV of usernames but the connection got terminated while the script was running. Here's what I wrote:
import twint
import pandas as pd
def twint_scrape(username, output, since='2017-05-10', until='2019-01-07'):
c = twint.Config()
c.Username = username
print("Scraping Tweets for ".format(c.Username))
c.Since = since
print("Starting date: ".format(c.Since))
c.Until = until
print("End date: ".format(c.Until))
c.Store_csv = True
c.Hide_output = True
c.Output = output
twint.run.Search(c)
return None
names_accounts = pd.read_csv('./names_accounts.csv')
usernames = names_accounts['Account']
for username in usernames:
print("Current username: ".format(username))
twint_scrape(username, username)
And this is the error message that I get:
Traceback (most recent call last):
File "./twitter_scraper.py", line 29, in <module>
twint_scrape(username, username)
File "./twitter_scraper.py", line 20, in twint_scrape
twint.run.Search(c)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 201, in Search
run(config)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File "C:UsersseantAnaconda3libasynciobase_events.py", line 573, in run_until_complete
return future.result()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 121, in main
await self.tweets()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 97, in tweets
await self.Feed()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 40, in Feed
response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 58, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=headers)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 89, in Request
return await Response(session, url, params)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 94, in Response
async with session.get(url, ssl=False, params=params) as response:
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 1005, in __aenter__
self._resp = await self._coro
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 497, in _request
await resp.start(conn)
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "C:UsersseantAnaconda3libsite-packagesaiohttpstreams.py", line 588, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054] 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다
The Korean in the last line is basically saying that the connection has been terminated by a remote host.
Is there anyway that I can keep the connection alive while keeping my script running? Any feedback would be greatly appreciated. Thanks!
python aiohttp
I'm currently using a library called Twint that is used for collecting Tweets. I wrote a short script to collect the Tweets from a CSV of usernames but the connection got terminated while the script was running. Here's what I wrote:
import twint
import pandas as pd
def twint_scrape(username, output, since='2017-05-10', until='2019-01-07'):
c = twint.Config()
c.Username = username
print("Scraping Tweets for ".format(c.Username))
c.Since = since
print("Starting date: ".format(c.Since))
c.Until = until
print("End date: ".format(c.Until))
c.Store_csv = True
c.Hide_output = True
c.Output = output
twint.run.Search(c)
return None
names_accounts = pd.read_csv('./names_accounts.csv')
usernames = names_accounts['Account']
for username in usernames:
print("Current username: ".format(username))
twint_scrape(username, username)
And this is the error message that I get:
Traceback (most recent call last):
File "./twitter_scraper.py", line 29, in <module>
twint_scrape(username, username)
File "./twitter_scraper.py", line 20, in twint_scrape
twint.run.Search(c)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 201, in Search
run(config)
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 153, in run
get_event_loop().run_until_complete(Twint(config).main())
File "C:UsersseantAnaconda3libasynciobase_events.py", line 573, in run_until_complete
return future.result()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 121, in main
await self.tweets()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 97, in tweets
await self.Feed()
File "C:UsersseantAnaconda3libsite-packagestwintrun.py", line 40, in Feed
response = await get.RequestUrl(self.config, self.init, headers=[("User-Agent", self.user_agent)])
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 58, in RequestUrl
response = await Request(_url, params=params, connector=_connector, headers=headers)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 89, in Request
return await Response(session, url, params)
File "C:UsersseantAnaconda3libsite-packagestwintget.py", line 94, in Response
async with session.get(url, ssl=False, params=params) as response:
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 1005, in __aenter__
self._resp = await self._coro
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient.py", line 497, in _request
await resp.start(conn)
File "C:UsersseantAnaconda3libsite-packagesaiohttpclient_reqrep.py", line 844, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "C:UsersseantAnaconda3libsite-packagesaiohttpstreams.py", line 588, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054] 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다
The Korean in the last line is basically saying that the connection has been terminated by a remote host.
Is there anyway that I can keep the connection alive while keeping my script running? Any feedback would be greatly appreciated. Thanks!
python aiohttp
python aiohttp
asked Mar 28 at 1:52
SeankalaSeankala
5781 gold badge4 silver badges19 bronze badges
5781 gold badge4 silver badges19 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389040%2fhow-to-prevent-python-aiohttp-clientoserror%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389040%2fhow-to-prevent-python-aiohttp-clientoserror%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown