For anyone reading this that is not not on BYJU's Future School Coding Curriculum, This is a fake story, that they provide to you, so that you have a "problem" to solve with code. Story: Our Sun is dying! The world is in an emergency as we are about to lose our star. All groups of scientists around the world have gathered together and created a technology to shift our Earth into another solar system, but which one exactly? Which star out there is safe and welcoming to our Earth? You have been assigned the task to research about stars so that we can choose the best one for us!
Getting Started:
- Open your VS Code editor.
- Create a virtual environment.
- Source the virtual environment.
- Install bs4 and requests using pip. *We are not going to use Selenium for this project
Specific Tasks to complete the Project:
- Understand the website we want to scrape first: Brightest stars in universe.
- Let’s decide the headers we will keep for our study: ● Name ● Distance ● Mass ● Radius
- Study the page in inspection mode to understand the patterns. You can use the following questions: ● How have they structured their HTML? ● How many tables have they used? ● Is there any specific pattern in the attributes each of the HTML tags has?
- Device a strategy on how to scrape and structure your code.
- Observe the HTML of the page
- Import all important/relevant modules.
- Define the START_URL, headers and an empty list to store the star’s data.
- Get the HTML page with requests module.
- Try to create a CSV by fetching one row from any of the tables. ● This need not be all the data. This will be continued in the next project and we will scrape all the data.
Submitting the Project:
- Upload your completed project to your own github account.
- Create a new repository named “ Web scraping 1”.
- Upload working code to this github repository.
- Enable Github pages for the repository.
- Copy the link to the github pages link in the Student Dashboard. link to the github pages link in the Student Dashboard.
Hints:
- On getting the HTML page with requests module, you might get an SSL error. Add verify=False with the request and it will not verify for a secure connection.
- Notice the unit of dimensions of the star data such as radius, distance and mass. If you are scraping from different sources make sure the units are the same, if not then we have to convert them.
- Your observations may be: ● There is only one table on the page ● Headings of the table are in tag ● All the star’s data rows are tags