Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 托管在Amazon EC2 linux实例上的scrapyd实例的输入/输出_Python_Amazon Web Services_Web Scraping_Scrapy_Scrapyd - Fatal编程技术网

Python 托管在Amazon EC2 linux实例上的scrapyd实例的输入/输出

Python 托管在Amazon EC2 linux实例上的scrapyd实例的输入/输出,python,amazon-web-services,web-scraping,scrapy,scrapyd,Python,Amazon Web Services,Web Scraping,Scrapy,Scrapyd,最近,我开始使用scrapy构建web刮板。最初,我使用scrapyd在本地部署了我的scrapy项目 我构建的scrapy项目依赖于从CSV文件访问数据来运行 def search(self, response): with open('data.csv', 'rb') as fin: reader = csv.reader(fin) for row in reader: subscriberID = row[0]

最近,我开始使用scrapy构建web刮板。最初,我使用scrapyd在本地部署了我的scrapy项目

我构建的scrapy项目依赖于从CSV文件访问数据来运行

 def search(self, response):
    with open('data.csv', 'rb') as fin:
        reader = csv.reader(fin)
        for row in reader:
            subscriberID = row[0]
            newEffDate = datetime.datetime.now()
            counter = 0
            yield scrapy.Request(
                url = "https://www.healthnet.com/portal/provider/protected/patient/results.action?__checkbox_viewCCDocs=true&subscriberId=" + subscriberID + "&formulary=formulary",
                callback = self.find_term,
                meta = {
                    'ID': subscriberID,
                    'newDate': newEffDate,
                    'counter' : counter
                    }
                )
它将刮取的数据输出到另一个CSV文件

 for x in data:
        with open('missing.csv', 'ab') as fout:
            csvwriter = csv.writer(fout, delimiter = ',')
            csvwriter.writerow([oldEffDate.strftime("%m/%d/%Y"),subscriberID,ipa])
            return
我们正在构建一个需要访问和运行这些爬行器的应用程序的初始阶段。我决定在AWS EC2 linux实例上托管我的scrapyd实例。部署到AWS非常简单()

如何向AWS EC2 linux实例上运行的scrapyd实例输入/输出刮取的数据?

编辑: 我假设传递一个文件

curl http://my-ec2.amazonaws.com:6800/schedule.json -d project=projectX -d spider=spider2b -d in=file_path

这是正确的吗?我如何从这个爬行器运行中获取输出?这种方法有安全问题吗?

S3是一种选择吗?我这么问是因为你已经在使用EC2了。如果是这种情况,您可以从S3读/写

我有点困惑,因为你提到了CSV和JSON格式。如果您正在阅读CSV,您可以使用。无论哪种方式,您都可以使用spider的
\uuuuu init\uuuuu
启动请求
方法读取S3

关于输出,说明如何使用提要导出将爬网的输出写入S3

相关设置:


谢谢,这就是我要找的。我编辑了我的问题,以使它不那么令人困惑