Skip to main content

爬虫端部署说明

一、概述

  • 爬虫框架分三个部分:调度中心、爬虫端、ADSL端。调度中心负责调度任务,爬虫端将任务发送给调度中心,调度中心存储在Redis里面;
  • ADSL端向调度中心取任务,然后负责下载;
  • 下载完成后将任务结果送到调度中心,调度中心存储在Redis里面;
  • 最后爬虫端从调度中心获取结果。

二、爬虫端

爬虫端的部署主要是环境的搭建,具体分两步:

1.Python环境

用pip安装Twisted 18.9.0,treq 18.6.0以及别的依赖包 手动安装MySQL-python包

2.爬虫端框架代码

将dmhe目录下面的crawler和lib目录里面的代码放到服务器上,并将dmhe路径加入Python的根路径里面 如果使用virtualenv,可以把client_demo/.spider/dmhe目录放到指定的virtualenv下面。比如有一个spider的虚环境,把dmhe目录拷贝到~/.spider/下面

三、接口说明

1.连接服务器:/connect/

2.断开服务器:/disconnect/

3.发送任务:/task/

四、参数说明

1.Crawler对象参数

名称 含义 user_id 用户名 name 任务名称 priority 任务优先级 1:低优先级 2:中优先级 3:高优先级 db_params 数据库参数 user_agent user_agent

2.Request对象参数

名称 含义

  • task_id 任务id
  • url 待抓取URL
  • headers 请求头(dict)
  • data 请求数据,POST请求有效
  • redirect 是否支持跳转,默认支持(1)
  • verify 是否做https验证,默认支持(1)
  • is_head 是否发送HEAD请求,默认不发送(0)
  • return_header 是否返回响应头,默认不返回(0)
  • encoding 页面编码,默认不指定
  • timeout 超时时间,默认30s
  • retry_times 抓取失败重试,默认3
  • extract_type 解析类型

0:不解析 (获取纯页面)

  • response 返回的主要内容: {'body': '', 'code': , 'url_real': '', 'uid': '', 'success': , 'url': '', 'tid': ''}

1:解析百度PC排名结果

  • response 返回的主要内容: {'domain': '', 'title': '', 'url': '', 'url_bd': '', 'rank': , 'id': , 'alading': }

2:解析百度移动排名结果

  • response 返回的主要内容: {'domain': '', 'title': '', 'url': '', 'url_bd': '', 'rank': , 'id': , 'alading': }

3:解析百度真实URL --- 说明: 获取百度百度真实url时,需设置 is_head=1

4:解析百度PC URL是否收录

5:解析360PC排名结果

6:解析360移动排名结果

7:解析搜狗PC排名结果

8:解析搜狗移动排名结果

9:解析网页TDK

  • response 返回的主要内容: {'keywords': '', 'keywords': '', 'title': ''}
  • priority: int, 请求优先级(只有页面抓取支持):

2:中优先级 3:高优先级

  • kwargs 其他参数 字典 resp会返回这个参数,如果需要根据不同页面做不同的解析处理,可以使用这个字段

参考脚本阅读: 1. sample 文件下 insert_sample.py 2. 主目录下的 demo.py demo2.py

Metadata

Release files for wd-crawler-client 6.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wd-crawler-client 6.0.2
File Size Uploaded Provenance Actions
wd-crawler-client-6.0.2.tar.gz 30.5 kB Without provenance Details for wd-crawler-client-6.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wd-crawler-client 6.0.2
File Interpreter ABI Platform Actions
wd_crawler_client-6.0.2-py2.py3-none-any.whl Python 2, Python 3 none any Details for wd_crawler_client-6.0.2-py2.py3-none-any.whl

Total release size: 61.9 kB

Release files / wd-crawler-client-6.0.2.tar.gz

Download URL wd-crawler-client-6.0.2.tar.gz
Size 30.5 kB
Tags Source
SHA-256 checksum
How to use checksums
64461f52d1a79c55f06b96e7081e6927661529eefe252db68e150af0aa1cea49
BLAKE2b-256 checksum
How to use checksums
cb8be0e9cda47454dafa26bdf28fa63da5663a584419c78039d7ae525d07dbeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.6

Release files / wd_crawler_client-6.0.2-py2.py3-none-any.whl

Download URL wd_crawler_client-6.0.2-py2.py3-none-any.whl
Size 31.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
efd3b4ca72c6b18493c61428d63a2305e53bcc589fb52a209ba9b49440a76de6
BLAKE2b-256 checksum
How to use checksums
c3480dda58262c8904b8e59ca7a0898e535c207d3d447de3f70cf9379b976123
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.6

Security for wd-crawler-client 6.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page