This article mainly introduces how to save collected data to mongodb using the scrapy custom pipeline class. it involves scrapy's skills in collecting and operating mongodb databases and has some reference value, for more information about how to save collected data to mongodb, see the example in this article. Share it with you for your reference. The details are
The example in this paper describes how the Scrapy custom pipeline class implements the method of saving the collected data to MongoDB. Share to everyone for your reference. Specific as follows:
# Standard Python Library imports# 3rd party modulesimport pymongofrom scrapy import logfrom scrapy.conf import SETTINGSFR Om scrapy.exceptions Import dropitemclass mongodbpipeline (object): def __init__ (self):
over.Initializepalette ();double[,] x = null;double[,] y = null;double[,] z = null;double[,] values = NULL;Creategeometrypipe (out x, off y, out z);Createvalueswaterdrops (out values);Updatemesh (x, y, z, values);V.surfacemeshseries3d.add (_mesh);V.yaxisprimary3d.units.text = "°c";_chart. EndUpdate ();SummarizeContour Topographic map can be used synthetically to judge the condition of the sight, hydrological characteristics of water system, climatic characteristics, topography and location sele
The example in this article describes the Scrapy custom pipeline class implementation method that saves data collected to MongoDB. Share to everyone for your reference. as follows:
# Standard Python Library Imports # 3rd party modules import Pymongo to scrapy import lo G from scrapy.conf Import settings from scrapy.exceptions Import Dropitem class Mongodbpipeline (object): Def __init__ (SE LF): Sel
operation of another or more processes in one process IPC communication queues queue Pipeline pipeI. interprocess communication (Queues and pipelines)Determine if the queue is emptyFrom multiprocessing Import Process,queueq = Queue () print (Q.empty ())Execution output: TrueDetermine if the queue is full From multiprocessing Import Process,queueq = Queue () print (Q.full ())Execution output: FalseIf the queue is full, then the operation to increment
;//fix him a pinch . - the PrivateString name;Bayi transient intAge//cannot be serialized after use of transient the StaticString country= "cn";//Static also cannot be serialized thePerson (String name,intage,string Country) { - This. name=name; - This. age=Age ; the This. country=Country; the } the PublicString toString () { the returnname+ "=" +age+ "=" +Country; - } the}Dark Horse programmer--java Basic--io Stream (iii)-sequ
Dynamic | The main idea of the data has been solved, the following start to write detailed design (in the Sybase ASE database for example, others to expand):
1. Establish the middle-tier table vdt_columns, which is used to build the column data in the pipeline.
To perform similar code generation:
Ls_sql = "CREATE Table Vdt_columns" ("
Ls_sql + = "UID int nul
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.