如何防止Python aiohttp ClientOSError?

时间:2019-03-28 01:52:14

标签: python aiohttp

我当前正在使用一个名为Twint的库来收集推文。我编写了一个简短的脚本,用于从用户名CSV收集推文,但是在脚本运行时连接已终止。这是我写的:

<?php
   session_start();
   include("db_connect.php");

if(isset($_POST['submit'])){
$item = $_POST['item'];
if(empty($item)) {
  $errors = "you must enter something";
}
else{
  mysqli_query("INSERT INTO a4_todolist (item) VALUES ('$item')");
  header('location: index.php');
}
}

$a4_todolist = mysqli_query("SELECT * FROM a4_todolist");
?>



<!DOCTYPE html>
<html>
<head>
<title> Assignment 4 - To Do List </title>
<link rel ="stylesheet" type ="text/css" href="style.css">
</head>
<body>
<div class "head">
  <h2> To Do </h2>
</div>

<form method= "POST" action = "index.php">
<?php if (isset($errors)) { ?>
 <p><?php echo $errors; ?></p>
  <?php } ?>



 Item <input type = "text" name= "item" class="item_input">
  Author <input type = "text" name= "author" class="author_input">
  <button type = "submit" class="add-btn" name="submit"> Add Task 
  </button>
  </form>
  <table>

 <tbody>
    <?php while ($row = mysqli_fetch_array($a4_todolist)) { ?>
    <tr>
      <td class="id"> <?php print  $row['id']; ?> </td>
      <td class="item"> <?php echo $row['item']; ?> </td>
    </tr>
   <?php } ?>

</tbody>
</table>
</thread>


</body>
</html>

这是我收到的错误消息:

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)

最后一行中的韩语基本上是说该连接已由远程主机终止。

无论如何,我可以在保持脚本运行的同时保持连接状态吗?任何反馈将不胜感激。谢谢!

0 个答案:

没有答案