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

想提两个功能建议 #7

Closed
csujedihy opened this issue Jun 22, 2017 · 10 comments
Closed

想提两个功能建议 #7

csujedihy opened this issue Jun 22, 2017 · 10 comments

Comments

@csujedihy
Copy link

csujedihy commented Jun 22, 2017

第一个是多个session的时候,generateMD.js生成的README.md里面的I've solved xxx/xxx problems (xx problems for a fee).能够把所有session算在一起,其实有个简单办法就是看本目录里面有多少个就说明solved多少个,然后再爬一个总题数。

第二个是提供cookie选项,而可以免帐号密码,这样爬完之后,自己再打开leetcode就不用重新登录了。

很好用的爬虫,谢谢!

@Ma63d
Copy link
Owner

Ma63d commented Jun 22, 2017

好的,非常感谢你的建议。
第一点,请问一下多个 session 是什么意思? 不好意思,我已经许久没有用 leetcode 了,所以已经有点迷糊了。。
第二点的话是这样的, leetcode 给 cookie 的时长设置得比较短。即使你是不用爬虫,几天不登录你也会发现 leetcode 要你重新登录。这意味着用户会需要隔三差五的自己手动更换 cookie。即使增加了 cookie 选项,可能还不如直接使用用户名密码来的方便。

用密码的方式也就是爬完之后重新点一下登录,因为浏览器可以记住密码,所以这一步也不会很麻烦,用 cookie 的话还要登录后自行取出 cookie 出来写入配置文件,这个步骤其实反而是更加麻烦了一点。

周末会重新优化一下 README.md 文件的内容,比如I've solved xxx/xxx problems (xx problems for a fee).这样的语句可能会使用等 badges 进行替换。
另外,会允许用户自定义 README.md 的模板文件,让用户自定义自己想呈现的内容,使用{total},{hard},{medium},{easy} 等插值形式插入爬虫结果。同时也会增加一些自定义存放目录的配置。

所以如果你还有什么需求,可以尽管跟我沟通。

@csujedihy
Copy link
Author

csujedihy commented Jun 22, 2017 via email

@Ma63d
Copy link
Owner

Ma63d commented Jun 22, 2017

竟然还有 session 这种操作? 我周末研究一下。到时候 cookie 选项的功能也会加上。

@csujedihy
Copy link
Author

棒极了!

@Ma63d
Copy link
Owner

Ma63d commented Jun 25, 2017

@csujedihy

第一个是多个session的时候,generateMD.js生成的README.md里面的I've solved xxx/xxx problems (xx problems for a fee).能够把所有session算在一起,其实有个简单办法就是看本目录里面有多少个就说明solved多少个,然后再爬一个总题数。

看本目录里面有多少个就说明solved多少个

本目录是什么意思? 你说的目录是什么目录?

我看了一下,把所有的 session 的 AC 信息统计在一起无法实现,目前具备的信息是:

  • 通过 post session/ 接口能获取到每个 session 的 AC 的总题数
  • 获取到当前 active 的 session 的具体 AC 的题目列表

因此,不能统计出所有 session 总共 AC 了多少题,因为 session 之间 AC 的题目肯定是有重复的,不能简单累加, 而目前不能获取到每个 session AC 的题目列表,无法去除重复。

所以目前能做到的就是获取到所有 session 中的最多的那个 AC 了多少题。然后在 I've solved xxx/xxx problems 里呈现出来。但是这样也有问题,我呈现的信息是我最多的那个 session 的,但是我爬取的东西却不是这个 session 的 solutions。那就会出现,我 README.md 里说我总共 AC 了400题,但是我爬下来存在文件夹里的却只有10几题,因为我这是新开的 session。。。。。。

所以 session 的功能不会去实现。

@csujedihy csujedihy reopened this Jun 25, 2017
@csujedihy
Copy link
Author

我想得也不周到,我的意思是solutions目录下已经爬到多少个题目就表明solved多少个了。其实多个session总共solved多少有办法实现,但是会算上非算法题。就是去个人profile里面爬。也就是这个地址https://leetcode.com/username。

@Ma63d
Copy link
Owner

Ma63d commented Jun 26, 2017

@csujedihy

但是这样也有问题,我呈现的信息是我最多的那个 session 的,但是我爬取的东西却不是这个 session 的 solutions。那就会出现,我 README.md 里说我总共 AC 了400题,但是我爬下来存在文件夹里的却只有10几题,因为我这是新开的 session。。。。。。

我其实已经说了, 即使能拿到我最多 solved 多少题或者我总共 solved 了多少题也是没用的,因为爬虫只能知道数量,而无法把具体的 solutions 爬取下来,只能爬取当前 active 的那个 session 的 solutions。这会导致刚刚上面那种情况,你自己说你 solved 了400题,但是你这个 github 仓库里明明只有10道题啊,围观你这个 github 仓库的人立马就会蹦出一个想法:“明明只 solved 了10道题,你唬谁呢?”

@csujedihy
Copy link
Author

确实

@Ma63d Ma63d closed this as completed Jun 26, 2017
@Ma63d
Copy link
Owner

Ma63d commented Jul 28, 2017

@csujedihy
新版本搞定了,demo 在这里
默认源码文件输出到 solutions 目录了,原先把一堆源码文件摆在当前目录下,使得 github 页面打开之后需要下拉很长才能看到 README.md 的内容。
现在也新增了 一些新功能,README.md 是由一个模板生成的,而用户可以编辑生成的模板,自己定义自己希望输出的 README.md 内容。

你希望的 cookies 功能,我今晚加上。

@csujedihy
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