Extracting Code From GeeksForGeeks Article
- requests- Requests allows you to send HTTP/1.1 requests extremely easily. This module also doesn’t come built-in with Python. To install simply type the given command in the terminal.
pip install requests
- bs4 :- Beautiful Soup(bs4) is a Python library for pulling data out of HTML and XML files. This module does not come built-in with Python. To install this, type the given command in the terminal.
pip install bs4
- Import modules
- Get the article name as input
- Initiate a get request to the URL
- Scrap the code and language name in which it is written using bs4
A lot can be done with this concept and using the given, for example you can directly save each code in separate file with their extension or you can scrap complete article and extract important information like writer details.
Below is the implementation.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course