2022年11月2日
摘要: import flask app = flask.Flask(__name_, static_folder='static', template_folder='templates') @app.route("/") def index(): return flask.render_temp1ate 阅读全文
posted @ 2022-11-02 22:53 不是霉蛋 阅读(18) 评论(0) 推荐(0)
摘要: """scrapy 保存管道数据""" from scrapy.exporters import CsvItemExporter class CsvPipeline: def __init__(self): # 文件存储初始化操作 self.file = open('filename.csv', ' 阅读全文
posted @ 2022-11-02 16:30 不是霉蛋 阅读(43) 评论(0) 推荐(0)
摘要: from pymongo import MongoClient class Spider(object): def __init__(self): # 将数据存储到数据库中 try: self.client = MongoClient('localhost', 27017) self.sina_db 阅读全文
posted @ 2022-11-02 16:20 不是霉蛋 阅读(24) 评论(0) 推荐(0)
摘要: import mysql.connector """数据模型类""" class QingHuaModel(object): def __init__(self, title, time, contents): self.title = title self.time = time self.con 阅读全文
posted @ 2022-11-02 16:14 不是霉蛋 阅读(30) 评论(0) 推荐(0)
摘要: """方式一(scrapy下):""" scrapy crawl 爬虫名 -o 保存的csv文件名 """方式二(常用):""" from scrapy.exporters import CsvItemExporter class CsvPipeline: def __init__(self): # 阅读全文
posted @ 2022-11-02 16:08 不是霉蛋 阅读(39) 评论(0) 推荐(0)