MCPcopy
hub / github.com/xianhu/PSpider

github.com/xianhu/PSpider @main sqlite

repository ↗ · DeepWiki ↗
83 symbols 242 edges 20 files 83 documented · 100%
README

PSpider

A simple web spider frame written by Python, which needs Python3.8+

Features of PSpider

  1. Support multi-threading crawling mode (using threading)
  2. Support using proxies for crawling (using threading and queue)
  3. Define some utility functions and classes, for example: UrlFilter, get_string_num, etc
  4. Fewer lines of code, easyer to read, understand and expand

Modules of PSpider

  1. utilities module: define some utilities functions and classes for multi-threading spider
  2. instances module: define classes of Fetcher, Parser, Saver for multi-threading spider
  3. concurrent module: define WebSpiderFrame of multi-threading spider

Procedure of PSpider

①: Fetchers get TaskFetch from QueueFetch, and make requests based on this task
②: Put the result(TaskParse) of ① to QueueParse, and so Parser can get task from it
③: Parser gets task from QueueParse, and parses content to get new TaskFetchs and TaskSave
④: Put the new TaskFetchs to QueueFetch, and so Fetchers can get task from it again
⑤: Put the TaskSave to QueueSave, and so Saver can get task from it
⑥: Saver gets TaskSave from QueueSave, and saves items to filesystem or database
⑦: Proxieser gets proxies from web or database, and puts proxies to QueueProxies
⑧: Fetcher gets proxies from QueueProxies if needed, and makes requests based on this proxies

Tutorials of PSpider

Installation: you'd better use the first method
(1)Copy the "spider" directory to your project directory, and import spider
(2)Install spider to your python system using python3 setup.py install

See test.py

TodoList

  1. More Demos
  2. Distribute Spider
  3. Execute JavaScript

If you have any questions or advices, you can commit "Issues" or "Pull requests"

Core symbols most depended-on inside this repo

update_number_dict
called by 21
spider/concurrent/threads_pool.py
get_number_dict
called by 15
spider/concurrent/threads_pool.py
add_a_task
called by 7
spider/concurrent/threads_pool.py
get_a_task
called by 4
spider/concurrent/threads_pool.py
finish_a_task
called by 4
spider/concurrent/threads_pool.py
get_proxies_flag
called by 3
spider/concurrent/threads_pool.py
is_ready_to_finish
called by 3
spider/concurrent/threads_pool.py
from_task_fetch
called by 2
spider/utilities/ctask.py

Shape

Method 52
Class 24
Function 7

Languages

Python100%

Modules by API surface

spider/utilities/ctask.py15 symbols
spider/concurrent/threads_pool.py12 symbols
test.py11 symbols
spider/utilities/cresult.py8 symbols
spider/concurrent/threads_inst/base.py7 symbols
spider/utilities/functions.py4 symbols
spider/utilities/cfilter.py4 symbols
spider/instances/inst_fetch.py4 symbols
spider/instances/inst_save.py3 symbols
spider/instances/inst_proxies.py3 symbols
spider/instances/inst_parse.py3 symbols
spider/concurrent/threads_inst/fetch.py3 symbols

For agents

$ claude mcp add PSpider \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact