r/learnjavascript • u/Saci-Pioneiro • Apr 03 '26
Non tech person trying to learn REGEX and scrapping in Javascript/html: where do I begin?
Basically, title.
I don't have any experience with javascript besides an introductory programing course a decade ago in another language (which is how I know about regex in the first place).
My goal is to build a website that will apply regex rules to a text using github pages. I also want to learn to download text content from websites and convert them to markdown. For example, I want to learn how to download the content of a wikipedia page and convert it to markdown, keeping it formatted, but I don't want the whole wikipedia page (images, links that are outside the main article, etc). I've already vibecoded a version and it helped me, but I need to be able to improve it and review it to know it is doing things properly.
How to I get from knowing nothing to learning those things in a couple weeks or months?
My goal is not to be the ultimate l33t c0d3r h@ck3rmann 3000, only to automate somethings in my current workflow. It's something that I have a couple weeks/months to learn.
What resources do you suggest I learn to reach my goals? I'm thinking the backbone of what I need is a good regex course, however I must learn the basics of javascript and github pages before.
Please, keep in my that my needs are specific and I'll likely have to build the solutions because there are a lot of specificities involved in what I'm trying to do. Therefore, available software likely won't solve my issues (I'm willing to listen to FOSS suggestions, though).
Thank you for your help.
5
u/StruggleOver1530 Apr 03 '26
This sounds like something a LLM would do much better than regex.
Also you don't need to know any regex to scrape text off a website you jeed to find a library that will do it for you, and learn how to make a web request to get the data.
2
u/33ff00 Apr 03 '26
Dare I ask what you will be using the regex for
1
u/Flashy-Guava9952 Apr 03 '26
Oldie but goodie: https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags
1
u/jb092555 Apr 04 '26
The dwarves there parsed too greedily and too deep.
1
u/TheZintis Apr 04 '26
If you are trying to consume HTML pages, I'd recommend a javascript library like Cheerio. There are others, I haven't stayed current with it.
Basically it uses Node.js flavor of javascript (in the terminal, not the browser), pings the page to get the raw HTML, then parses it into a DOM tree (this might be inaccurate). Then you use selectors, like CSS selectors, and a handful of utility functions to wander around the HTML finding the data you want.
Advantage: once you get it working, it'll go get your data quickly and easily.
Disadvantage: if the page changes structure, CSS classes, etc... it may break the code you've written that looks around the HTML page.
This would require you to learn/install Node.js and have a reasonable understanding of basic JS. It's also not a quick-and-easy solution. Getting a basic prototype up and running is probably 10-30 minutes. But getting your logic to correctly and consistently grab the data from the page could be anywhere from minutes to hours.
Also this hasn't solved the conversion to markdown, but I'm not sure how to handle that so best of luck.
1
u/Foreign_Analysis_931 Apr 04 '26
learn to use playwright in stealth mode and basic anti-scraping evasion.
people are much more aware of scrapers and they actively try to screw you over.
https://www.youtube.com/watch?v=E4wU8y7r1Uc
LLMs will be very useful to learn more
1
u/ChaseShiny Apr 03 '26
Someone with more experience will probably correct me anon, but here's my take.
First, start with MDN's introduction to Regex. That should give you an idea of how to get started. Next, use regex101. Huzzah! A cheat sheet with all the commands and a way to test your version.
I would suggest using strings to build pieces. Regex can look very confusing when it gets long, so concate separate parts and use string templates for parts that go inside of other parts. You then convert the string together using the constructor
AI is pretty good at helping you figure out cases that you didn't consider, but don't just trust it completely.