Last active
December 7, 2025 01:25
-
-
Save Sarverott/6af725d590a2fdf4b704a657980db9b6 to your computer and use it in GitHub Desktop.
playing around https://docs.python.org/3/library/ with devTools coding for fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* TEST: URL == 'https://docs.python.org/3/library/'*/ | |
| [ | |
| ...new Set( | |
| Array.from( | |
| document.querySelectorAll("a") | |
| ).map( | |
| (x)=>x.href | |
| ).filter( | |
| (x)=>x.includes('https://docs.python.org/3/library/') | |
| ).map( | |
| (x)=>x.substring( | |
| "https://docs.python.org/3/library/".length | |
| ).split( | |
| ".html" | |
| ) | |
| ).filter( | |
| (x)=>x.length==2 | |
| ).map( | |
| (x)=>x[0] | |
| ) | |
| ) | |
| ] | |
| //for me above code returns array with 268 elements, | |
| //including 'intro' and 'index' that are not libraries, | |
| //these are common introduction and index list | |
| //to filter out laminal spaces like that among docs we will need some kind of checking method | |
| // I have 2 proposals of next step: | |
| // - **test it in environment**: usage of Pyodide that acts as python emulator sandbox for webassembly (https://pyodide.org/en/stable/) | |
| // - **read these docs more**: usage of Puppeteer that acts as nodejs web browser automation tool (https://pptr.dev/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* TEST: URL == 'https://docs.python.org/3/library/inspect.html#inspect.getfile'*/ | |
| [ | |
| ...new Set( | |
| Array.from( | |
| document.querySelectorAll("a") | |
| ).map( | |
| (x)=>x.href | |
| ).filter( | |
| (x)=>x.includes( | |
| document.location.href.split("#")[0] | |
| ) | |
| ) | |
| ) | |
| ] | |
| //v2 | |
| [ | |
| ...new Set( | |
| Array.from( | |
| document.querySelectorAll("a") | |
| ).map( | |
| (x)=>x.href | |
| ).filter( | |
| (x)=>( | |
| x.split("#").length > 1 | |
| && | |
| x.includes( | |
| document.location.href.split("#")[0] | |
| ) | |
| ) | |
| ).map( | |
| x=>x.split("#")[1] | |
| ) | |
| ) | |
| ] | |
| // instead of writting updated "v2" addon it can be handled by secong git commit next time | |
| // remember to use familiar with what you do descriptions - you adds that commit messages for your own self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* TEST: URL == 'https://docs.python.org/3/library/index.html#library-index'*/ | |
| HREF_LIST = Array.from( | |
| document.querySelectorAll("a") | |
| ).map( | |
| (x)=>x.href | |
| ); | |
| //what to use | |
| console.log(HREF_LIST.filter( | |
| x=>x.match( | |
| new RegExp(/^https\:\/\/docs\.python\.org\/3\/library\/([\w\d\.]+)\.html$/, "i") | |
| ) | |
| )) | |
| //or | |
| console.log(HREF_LIST.filter( | |
| x=>x.includes( | |
| 'https://docs.python.org/3/library/' | |
| ) | |
| )) | |
| //these methods are same direction but not same targeting | |
| //both methods can lead to same results but example | |
| //with regexp will ignore links with paragraph pointing | |
| /*( | |
| includes alike 'https://docs.python.org/3/library/termios.html' | |
| excludes alike 'https://docs.python.org/3/library/termios.html#termios.tcsetattr' | |
| )*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment