Code Monkey home page Code Monkey logo

Comments (18)

bonfy avatar bonfy commented on August 17, 2024

目前 leetcode 上面所有的语言都已经支持了 只要修改 config.cfg文件即可

language = python 改成你要爬取的solution语言即可

[leetcode]

username = username
password = password
language = python
repo = https://github.com/bonfy/leetcode

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

我的意思是能否一次性爬取所有语言并生成对应的正确readme文件

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

不好意思,看错了。

只有两种语言的话 也是可以处理的。

这个多语言问题我当时也考虑过,因为我自己也刷过python, javascript, 当时想的方法是 每种语言都要重新加载一次,这样的话,如果选择语言过多,会导致问题:

  1. 程序处理比较慢,线性增长
  2. Readme里面language一栏,太多语言的话影响排版(极端情况9种一起写,9个肯定排版影响)

如果就是两个的话,其实是可以做的。

@Ma63d 也想问下,要不要设置下语言个数上限,多了会影响排版,主要是排版问题

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

我之前使用的时候出现的情况主要是这样的:
我因为使用jsjava两种语言刷题,
我将config.cfg中的language设置为java之后,
爬取下来的代码出现了问题,比如我第一题是用js写的,
但是python代码去爬的时候只检测该题是否AC,然后就去submission里面找AC的submission,
然后爬取代码,爬下来时并按照config.cfg中的设置去处理爬下来的代码,
因此,爬下来的代码其实是js的,但是后缀名写的是java,最后markdown里面也写的是java
而且如果我一题用了多种语言刷,只会下载一个ac解,并且显示的是config.cfg中设置的语言,并不是实际代码使用的语言.

我自己不会python 但是勉强看懂了你的代码,小小修改了一下,目前暂时可以正确的添加后缀名,markdown也能正确显示链接,但是不能爬取其他的语言,而且我不懂python语法,改出来的只能是全量爬取,指定题号的爬取会出错,前面一段时间用的时候就将就全量爬取,但是随着题数增加,全量爬取的时候实在不能忍受,而且用java,js解的题只能爬下来java的,所以我才来开了这个issue.

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

@bonfy 嗯 我明白你的代码的爬取过程,所以如果是多种语言爬取的话,那么必须得检查每一题的所有submissions而不是找到第一个Accepted的,必然会带来处理时间的线性增长.
而且似乎要实现多种语言爬取的话,在指定题号的增量爬取时生成的readme似乎很难处理,因为你必须爬了才知道以前那些题目是用哪些语言写的,目前直接按照https://leetcode.com/api/problems/algorithms/ 返回的json来处理 的方式应该不行了.

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

我java的暂时没测过,回去先整一个java的leetcode solution测下

关于那个所有AC的都去检查 ,这个问题 在我开的issue Modify the solutions count in Readme to meet the real solutions count in a certain language in setting #4 里面应该会解决

至于readme应该是可以处理的,先全部下载好代码,存进一个solutions list ,按条件写readme

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

排版的问题似乎不用担心,因为html的table是自适应的,某一列长度增长的会压缩其他列的长度,而且 他会自动换行,并且由于table的vertical-align:center 换行会自动垂直居中,排版不存在问题.

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

我试试用node写一个爬虫,用纯并行的方式看看会不会快一些.

from leetcode.

fancymax avatar fancymax commented on August 17, 2024

@Ma63d @bonfy 个人感觉还不如再开一个Repo?全部堆一起不乱吗?

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

我试了你的最新版代码, 现在检查到不是用config.cfg里指定的代码写的时候已经不会去下载了

@fancymax 不会有乱的感觉吧 比如这个 https://github.com/illuz/leetcodehttps://github.com/kamyu104/LeetCode

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

@fancymax 我有考虑再开一个repo ,然后好好整理下文件结构,上传到pypi,还有打包成exe做成windows程序

不过这里也想保留个单文件版的,方便大家下载使用

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

@Ma63d 2-3个语言效果是还可以

from leetcode.

fancymax avatar fancymax commented on August 17, 2024

@bonfy 感觉目前脚本算是很好用了。暂时没觉得有打包成exe的必要。

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

@fancymax 那这个打包exe可以缓缓,先传到pypi

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

@Ma63d @fancymax

修改完成,多个language只要用逗号分隔设置就可以了

目前的做法是 加载pass的language到self.items的pass_language中,然后根据pass_language下载相应的代码并且生成readme,效率也还可以

[leetcode]

username = username
password = password
language = python, javascript
repo = https://github.com/bonfy/leetcode

from leetcode.

Ma63d avatar Ma63d commented on August 17, 2024

速度真是快,赞
我用js也写了个, https://github.com/Ma63d/leetcode-spider
也支持爬多种语言的了, 不过遇到网络不好的时候有时会出问题

from leetcode.

bonfy avatar bonfy commented on August 17, 2024

如果语言设置多的话,排版还是有点不太满意

https://github.com/illuz/leetcode 里面是把标题截断保持长度不是太长

还是要再查查markdown table 是否可以设置 列宽 和 换行

from leetcode.

fancymax avatar fancymax commented on August 17, 2024

厉害啊~~

from leetcode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.