Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
39 lines (32 loc) · 1011 Bytes

File metadata and controls

39 lines (32 loc) · 1011 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
"""
Created on 2021-02-08 16:06:12
---------
@summary:
---------
@author: Boris
"""
import feapder
from feapder import Item, UpdateItem
class TestMongo(feapder.AirSpider):
__custom_setting__ = dict(
ITEM_PIPELINES=["feapder.pipelines.mongo_pipeline.MongoPipeline"],
MONGO_IP="localhost",
MONGO_PORT=27017,
MONGO_DB="feapder",
MONGO_USER_NAME="",
MONGO_USER_PASS="",
)
def start_requests(self):
yield feapder.Request("https://www.baidu.com")
def parse(self, request, response):
title = response.xpath("//title/text()").extract_first() # 取标题
for i in range(10):
item = Item() # 声明一个item
item.table_name = "test_mongo"
item.title = title + str(666) # 给item属性赋值
item.i = i + 5
item.c = "777"
yield item # 返回item, item会自动批量入库
if __name__ == "__main__":
TestMongo().start()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.