I'm learning a bit of web scraping with Python, how, why and when to use regex and or bs4 to parse html pages | Sololearn: Learn to code for FREE!

+1

I'm learning a bit of web scraping with Python, how, why and when to use regex and or bs4 to parse html pages

web scraping with Python

10/24/2017 4:43:35 AM

Donald Chinhuru

6 Answers

New Answer

+12

BeautifulSoup4 or bs4 allows you to strip and decompose the website to its building elements, so it deals with the HTML from the structure side - if at any point you need to deal with, let's say, the sixth hyperlink in the second row, third column of the table preceeded with two <div> tags. RegEx or re allows you to parse text itself, looking for character-specific matches inside it. So it finds even the most complex character combinations in the HTML file, kind of treating it like a text file. For most parsing tasks you probably need both :)

+8

@Sayan I'd rather treat it as a nice way to behave ;)

+7

No problem. Would you mind marking my answer as best in this case? :) It actually helps keeping my xp on the rise ;)

+1

thanks you Kuba..your answer have been helpful https://www.sololearn.com/discuss/811313/?ref=app

+1

😂😂😂@ kuba... that was hell of a cute demand

+1

😁😁😁 ok man i did