Skip to main content

IP 代理池

安装

pip install stand

启动

stand

使用

>>> from stand import get_proxy
>>> proxy = get_proxy()
>>> print(proxy)
'103.133.222.151:8080'

在 Scrapy 中使用 stand 作为代理

import scrapy
from scrapy.crawler import CrawlerProcess


class TestSpider(scrapy.Spider):
    name = 'test'
    start_urls = ['https://api.ip.sb/ip']

    def parse(self, response):
        print(response.meta['proxy'])
        print(response.text)


DOWNLOADER_MIDDLEWARES = {
    'stand.UserAgentMiddleware': 543,
    'stand.ProxyMiddleware': 600,
}
settings = dict(
    LOG_ENABLED=False,
    DOWNLOAD_TIMEOUT=30,
    DOWNLOADER_MIDDLEWARES=DOWNLOADER_MIDDLEWARES,
)


def run():
    process = CrawlerProcess(settings)
    process.crawl(TestSpider)
    process.start()


if __name__ == "__main__":
    run()

项目说明

  1. 当启动 stand 时, 首先会运行 crawl 函数从代理网站爬取代理 IP, 并将爬取到的结果存储在名为 stand.db (可通过 STAND_DIR 环境变量设置保存目录) 的 SQLite 数据库中, 每个 IP 有一个初始分数 2
  2. 然后会运行 validate 函数验证代理 IP 的有效性, 验证通过分数设置为最高值 3, 验证失败分数减 1, 当分数为 0 时删除该 IP
  3. 之后会定时运行 crawl 和 validate 函数分别爬取和验证 IP, 每20分钟爬取一次 IP, 每60分钟验证一次 IP

Metadata

Release files for stand 0.1.11

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

Source distribution (sdist)

Source distribution for stand 0.1.11
File Size Uploaded Provenance Actions
stand-0.1.11.tar.gz 7.9 kB Without provenance Details for stand-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stand 0.1.11
File Interpreter ABI Platform Actions
stand-0.1.11-py3-none-any.whl Python 3 none any Details for stand-0.1.11-py3-none-any.whl

Total release size: 17.9 kB

Release files / stand-0.1.11.tar.gz

Download URL stand-0.1.11.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
12e0ccd425e89ded5ead191c970af9720a11f41d551766cd6c2f3f1e3e1629b2
BLAKE2b-256 checksum
How to use checksums
1c5dd7ab516c55f4fc03e33c661221736ab9aafada5d513f958a92cf899d76b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.5 Windows/10

Release files / stand-0.1.11-py3-none-any.whl

Download URL stand-0.1.11-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f56d5c9ed595e973a5b5d47fb68906daaa1a7da660b28394a6797fa7ef13f7d3
BLAKE2b-256 checksum
How to use checksums
55170519dc222005c75f214cadcad912c5bac82e5a61705b0b151d7c70d80fa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.5 Windows/10

Security for stand 0.1.11

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

0.1.11 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