社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

ARR

ARR 最近创建的主题
ARR 最近回复了
6 年前
回复了 ARR 创建的主题 » 在python脚本中运行scrappy程序

正如错误所说,Quote5未定义,您需要在将其传递给方法之前定义Quote5。或者尝试这样的方法:

run_spider(“quotes5”)

编辑:

import WS_Vardata.spiders.quotes_spiders as quote_spider_module
def run_spider(spiderName):
    #get the class from within the module
    spiderClass = getattr(quote_spider_module, spiderName)
    #create the object and your good to go
    spiderObj= spiderClass()
    crawler = CrawlerRunner(get_project_settings())   #from Scrapy docs
    crawler.crawl(spiderObj)  

run_spider("QuotesSpider")

此脚本应与ws_vardata在同一目录中运行

所以在你的例子中:

- TEST
| the_code.py
| WS_Vardata
   | spiders
     | quotes_spider <= containing QuotesSpider class 
6 年前
回复了 ARR 创建的主题 » 如何在Python中加载多个JSON对象
[
    { 
      "a": 1,
      "b" : 2,
      "c" : {
              "d":3
            }
    },
    { 
      "e" : 4,
      "f" : 5,
      "g" : {
             "h":6
            }
    }
]

首先,您的JSON文件应该 像这样,第二次像json.loads一样加载文件(file.read())