Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在用回调函数on_list_page去获得列表页数据时候,无法真正add_url #162

Open
qizhenchao opened this issue May 17, 2022 · 2 comments

Comments

@qizhenchao
Copy link

在用回调函数on_list_page去获得列表页数据时候,
$options = array(
'method' => 'get',
'context_data' => $page_views,
);

$phpspider->add_url($content_url, $options);

这个方法不生效, 无法在content 页获得这个options 里的信息。
我猜想是这个$content_url已经在url列表里了, 无法重复再加入。

请问怎么解决这个问题?

@qizhenchao
Copy link
Author

看了看源码,我觉得这里可以处理一下。 我可以改吗:)

    $exists = queue::exists($key); 
            // 不存在或者当前URL可重复入
            if (!$exists || $allowed_repeat) 
            {
                // 待爬取网页记录数加一
                queue::incr('collect_urls_num');
                // 先标记为待爬取网页
                queue::set($key, time()); 
                // 入队列
                $link = json_encode($link);
                //根据采集设置为顺序采集还是随机采集,使用列表或集合对象 2018-5 BY KEN <a-site@foxmail.com>
                if (self::$configs['queue_order'] == 'rand')
                {
                    queue::sadd('collect_queue', $link);
                }
                else
                {
                    queue::lpush('collect_queue', $link);
                }
                $status = true;
            }

@owner888
Copy link
Owner

owner888 commented Jun 2, 2022

看了看源码,我觉得这里可以处理一下。 我可以改吗:)

    $exists = queue::exists($key); 
            // 不存在或者当前URL可重复入
            if (!$exists || $allowed_repeat) 
            {
                // 待爬取网页记录数加一
                queue::incr('collect_urls_num');
                // 先标记为待爬取网页
                queue::set($key, time()); 
                // 入队列
                $link = json_encode($link);
                //根据采集设置为顺序采集还是随机采集,使用列表或集合对象 2018-5 BY KEN <a-site@foxmail.com>
                if (self::$configs['queue_order'] == 'rand')
                {
                    queue::sadd('collect_queue', $link);
                }
                else
                {
                    queue::lpush('collect_queue', $link);
                }
                $status = true;
            }

可以呀, 改完给我提一个patch即可啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants