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

question #1

Open
young2333 opened this issue Jul 12, 2018 · 2 comments
Open

question #1

young2333 opened this issue Jul 12, 2018 · 2 comments

Comments

@young2333
Copy link

请问如何限制爬取电影的数量呢?

@monkey-soft
Copy link
Owner

monkey-soft commented Jul 13, 2018

请问如何限制爬取电影的数量呢?

@young2333 限制爬取电影数量,这个需要对代码进行改造下。大体思路是:TopWorkThread 类中增加判断 TaskQueue 中的 contentQueue 的大小逻辑。因为程序用到多线程,需要要考虑到线程安全,建议加个 锁。

另外补充下这几个类的作用:

  • middleQueue
    middleQueue 是一个队列,里面存放着带有电影详情页的电影分页的 url 地址。每个 url 地址(电影分页)有 25 部电影。

  • TopWorkThread
    TopWorkThread 的作用是依次从 middleQueue 中的获取一个 url 地址,然后访问该 url 地址。从返回结果中,解析出 电影详情页的 url 地址,然后存储到 ContentQueue 中。

@young2333
Copy link
Author

好的,谢谢回复

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