科技,树莓派,云计算服务

使用树莓派搭建爬虫服务器

2019-05-16  本文已影响0人  黄凯

为什么使用树莓派搭建自己的爬虫服务器?

准备好硬件

先安装散热片


IMG_20190517_112738.jpg

在固定到底板上,一共有四个螺丝


IMG_20190517_112725.jpg

查SD卡的那一侧先不安装


IMG_20190517_112717.jpg

固定好风扇


IMG_20190517_112704.jpg

完成!


IMG_20190517_112633.jpg

准备好刷卡环境

下载软件

写入SD卡

启动树莓派

配置WiFi

network:
        version: 2
        ethernets:
                eth0:
                        optional: true
                        dhcp4: true
        wifis:
                wlan0:
                        optional: true
                        dhcp4: true
                        access-points:
                                WIFISSID: {password: WIFIPASSWORD}
sudo netplan apply

远程管理树莓派

sudo apt update
sudo apt install python3-pip  python3-twisted python3-cffi python3-parsel python3-queuelib python3-pydispatch python3-hamcrest python3-redis
sudo pip3 install --no-deps w3lib==1.20.0 scrapy scrapyd
ubuntu@ubuntu:~$ scrapy
Scrapy 1.6.0 - no active project

Usage:
  scrapy <command> [options] [args]

Available commands:
  bench         Run quick benchmark test
  fetch         Fetch a URL using the Scrapy downloader
  genspider     Generate new spider using pre-defined templates
  runspider     Run a self-contained spider (without creating a project)
  settings      Get settings values
  shell         Interactive scraping console
  startproject  Create new project
  version       Print Scrapy version
  view          Open URL in browser, as seen by Scrapy

  [ more ]      More commands available when run from project directory

Use "scrapy <command> -h" to see more info about a command

配置scrapyd服务器

[scrapyd]
bind_address=0.0.0.0
ubuntu@ubuntu:~$ scrapyd
Removing stale pidfile /home/ubuntu/twistd.pid
2019-05-17T04:01:21+0000 [-] Removing stale pidfile /home/ubuntu/twistd.pid
2019-05-17T04:01:21+0000 [-] Loading /usr/local/lib/python3.6/dist-packages/scrapyd/txapp.py...
2019-05-17T04:01:22+0000 [-] Scrapyd web console available at http://0.0.0.0:6800/
2019-05-17T04:01:22+0000 [-] Loaded.
2019-05-17T04:01:22+0000 [twisted.scripts._twistd_unix.UnixAppLogger#info] twistd 17.9.0 (/usr/bin/python3 3.6.7) starting up.
2019-05-17T04:01:22+0000 [twisted.scripts._twistd_unix.UnixAppLogger#info] reactor class: twisted.internet.epollreactor.EPollReactor.
2019-05-17T04:01:22+0000 [-] Site starting on 6800
2019-05-17T04:01:22+0000 [twisted.web.server.Site#info] Starting factory <twisted.web.server.Site object at 0xffff8f405160>
2019-05-17T04:01:22+0000 [Launcher] Scrapyd 1.2.0 started: max_proc=16, runner='scrapyd.runner'

接下来的工作

上一篇 下一篇

猜你喜欢

热点阅读