a65420321a's recent timeline updates
a65420321a

a65420321a

V2EX member #310035, joined on 2018-04-19 22:17:40 +08:00
这个网站是怎么做的访问限制?
  •  1   
    程序员  •  a65420321a  •  Feb 26, 2021  •  Lastly replied by a65420321a
    8
    scrapy 如何在多个模块里共用一个数据库连接池
    Python  •  a65420321a  •  Jul 13, 2020  •  Lastly replied by a65420321a
    12
    动态变化的 js 如何逆向
    Python  •  a65420321a  •  Jun 11, 2020  •  Lastly replied by Harlaus
    13
    异步爬虫如何使用 https 代理?
    Python  •  a65420321a  •  Nov 6, 2018  •  Lastly replied by enrolls
    2
    多线程爬虫写入 mysql 特别的慢
    Python  •  a65420321a  •  Nov 10, 2018  •  Lastly replied by CEBBCAT
    30
    想请教一个问题,爬 boss 直聘时遇到的
    Python  •  a65420321a  •  Dec 26, 2018  •  Lastly replied by bigccz
    8
    a65420321a's recent replies
    Feb 26, 2021
    Replied to a topic by a65420321a 程序员 这个网站是怎么做的访问限制?
    @nekobest
    @reed2020
    @Jasmine2016
    @dingwen07
    好吧,这么看来是 ip 本身的问题了,这倒是好解决了
    谢谢各位大佬
    Feb 26, 2021
    Replied to a topic by a65420321a 程序员 这个网站是怎么做的访问限制?
    @lsvih 啊?普通的海外代理可以直接访问吗?为什么我挂 v 皮恩不行呢
    @Kobayashi
    看过的~你们说 pipeline 让我以为 middleware 可以调 pipeline 来着。。。
    @Kobayashi
    。。。pipeline 里面可以给 request 加代理吗?
    @Kobayashi
    我之前一直在纠结,怎么在 spider 里面直接调用 pipeline 的 redis 链接,没有相通,最后我是在 spider 里面声明了 redis 连接池,在 pipeline 和 middleware 通过 spider 参数直接调用 redis 链接
    现在看下来,在 pipeline 的 open_spider 中声明 redis 链接,在 spider 里面把需要筛选的东西处理成不同的 item,通过 pipeline 的 process_item 调用 redis 链接。。
    我没理解错吧?
    可是,如果这样的话,我需要在 middleware 里使用代理,也要用到 redis,这又要怎么搞。。。
    @996635

    额,你说的钩子指的是哪些?

    数据库链接搞定了
    在 spider 下__init__构建了 self.pool 和 self.conn
    然后在 pipeline 里通过 process_item 中的 spider 参数调用 spider.conn 可以复用数据库链接
    middleware 同样是通过 process_request 的 spider 参数

    话说,为啥我搜出来的都是说在 pipeline 下的 open_spider 里创建数据库链接,这样的话别的地方通过什么方式调用呢?
    @zdnyp


    from .settings import ITEM_KEY
    import json, redis

    class RedisPipeline:

    def __init__(self, redis_host, redis_port, redis_db):
    self.redis_host = redis_host
    self.redis_port = redis_port
    self.redis_db = redis_db

    @classmethod
    def from_crawler(cls, crawler):
    return cls(
    redis_host=crawler.settings.get('REDIS_HOST'),
    redis_port=crawler.settings.get('REDIS_PORT'),
    redis_db=crawler.settings.get('REDIS_DB')
    )

    def open_spider(self, spider):
    self.pool = redis.ConnectionPool(host=self.redis_host,
    port=self.redis_port,
    db=self.redis_db)
    self.conn = redis.StrictRedis(connection_pool=self.pool)
    print('#### pipelines.open_spider')

    def close_spider(self, spider):
    pass

    def process_item(self, item, spider):
    self.conn.rpush(ITEM_KEY, json.dumps(item))
    return item



    这样没错吧?
    我没搞懂的是,在 middleware 和 spider 里面要怎么调用这个 self.conn 呢?
    老哥们,视频 app 有没有类似阅读的
    Jun 10, 2020
    Replied to a topic by a65420321a Python 动态变化的 js 如何逆向
    @joesonw 太慢了。。。
    Jun 10, 2020
    Replied to a topic by a65420321a Python 动态变化的 js 如何逆向
    @takemeaway 之前是下载他的 js 运行的,不晓得什么情况现在不通。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1059 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 18ms · UTC 18:36 · PVG 02:36 · LAX 11:36 · JFK 14:36
    ♥ Do have faith in what you're doing.