我为scrapy编写了一个自定义命令:
from pyes import *
from eScraperInterface import settings
from django.core.management import setup_environ
setup_environ(settings)
from eScraperInterfaceApp.models import scrapedData
from eScraperInterfaceApp.eScraper_utils import eScraperUtils
#------------------------------------------------------------------------------
class indexData():
def __init__(self):
self.utilsOBJ = eScraperUtils()
conn = ES('127.0.0.1:9200')
conn.create_index("scraped_data")
def run(self):
for i in scrapedData.objects.filter():
data = {'productTitle':i.productTitle,'productSite':i.productSite,
'productURL':i.productURL,'productDesc':i.productDesc,
'productCategory':i.productCategory,'productSubCategory':i.productSubCategory,
'productMRP':i.productMRP,'productPrice':i.productPrice,'hasVariants':i.hasVariants,
'availability':i.availability,'currency':i.currency,'image_paths':i.image_paths}
a = self.utilsOBJ.create_Index(data)
print a
当我尝试使用scrapy shell命令时,出现了以下错误:
^{pr2}$
你在系统上安装了pythonmysqldb了吗? sudo apt get安装python mysqldb 或pip安装mysqldb
相关问题 更多 >
编程相关推荐