Watercress movie top250 Crawl and save in MongoDB

Source: Internet
Author: User
Tags logical operators

First, let's review the basic operations of MongoDB:

Database, collection, document Db,show dbs,use database name, drop database db. collection name. Insert ({}) db. collection name. Update ({condition},{$set: {}},{multi:true}) db. Collection name. Remove ({ Conditions}) DB collection name. Find ({conditional},{projection}). Limit (). Skip (). Sort (). Count (). DISTINCT () database add modify delete query Mysqlinsert update delete Selectredissetsetdelgetmongodbinsertupdateremovefind,aggregate

String
Hash
List
Set
Zset

Increase
Mysql:insert into table name (column) values (value)
Mongo:db. Collection name. Insert ({})

Modify:
Mysql:update table Name Set column = value where condition
Mongo:db. Collection name. Update ({conditional},{value $set},{modified multiple})

Delete:
Mysql:delete from table name where ....
Mongo:db. Collection name. Remove ({condition},{whether to delete more than one})

Inquire:
Db.stu.find ({},{})
Comparison operators, logical operators, $where
Limit (), skip (), sort (), count (), distinct ()

 

 

First use XPath to extract the information you want to crawl: The information we need to crawl in this project is: title, information, rating, Introduction

First page link: https://movie.douban.com/top250

Second page link: https://movie.douban.com/top250?start=25&filter=

Third page link: https://movie.douban.com/top250?start=50&filter=

Rule: https://movie.douban.com/top250?start=\d+&filter=

Title://a/span[@class = "title"][1]

Info://div[@class = "BD"]/p[1]/text ()

Rating://div[@class = "star"]/span[2]/text ()

Introduction://span[@class = "Inq"]/text ()

Then use Sscrapy startproject Douban to create the project

Sscrapy Genspider Dopuban movie.douban.com

Then write the following file in turn:

items.pydoubanmovie.pysettings.pypipelines.py

      

Watercress movie top250 Crawl and save in MongoDB

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.