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!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

24th Oct 2017, 4:43 AM
Donald Chinhuru
Donald Chinhuru - avatar
6 Answers
+ 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 :)
24th Oct 2017, 5:41 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 8
@Sayan I'd rather treat it as a nice way to behave ;)
24th Oct 2017, 3:12 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 7
No problem. Would you mind marking my answer as best in this case? :) It actually helps keeping my xp on the rise ;)
24th Oct 2017, 2:37 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
thanks you Kuba..your answer have been helpful https://www.sololearn.com/discuss/811313/?ref=app
24th Oct 2017, 2:21 PM
Donald Chinhuru
Donald Chinhuru - avatar
+ 1
😂😂😂@ kuba... that was hell of a cute demand
24th Oct 2017, 2:45 PM
sayan chandra
sayan chandra - avatar
+ 1
😁😁😁 ok man i did
24th Oct 2017, 3:34 PM
Donald Chinhuru
Donald Chinhuru - avatar