A parser is a program that collects data from the Internet, analyzes it and displays it in the desired format.
In this lesson, we will write a parser that will track the dollar exchange rate. We will use python (one of the best programming languages for working with information).
First you need to download the libraries (enter the code below in the command line)
requests - a library for getting the website code (information about the course is in the web page code)
bs4 - a library for working with HTML, CSS code (we will use it to search for the information we need in the code)
Create a dollar.py file (you can name it in a different way) and import all the necessary libraries:
We will parse from the site investing.com, so you need to save the URL of the page with the dollar exchange rate ( https://ru.investing.com/currencies/usd-rub ) as a variable
You also need to know your User Agent first. Just google "my user agent" and copy the string into a variable:
Now we need to get the page code:
Go to the site and press Ctrl+Shift+I. Now we see the page code directly in the browser. We click on the button on the top left (to select an element on the page) and select the text with the dollar rate (if we know where the text with the dollar rate is located in the code, we can access this part of the code each time and display this text). We learn that the course is stored in a tag with id equal to "late-late". Now let's create a soup variable to find the tag with the id we need:
Here is the entire parser code:
In this lesson, we will write a parser that will track the dollar exchange rate. We will use python (one of the best programming languages for working with information).
First you need to download the libraries (enter the code below in the command line)
You must reply before you can see the hidden data contained here.
bs4 - a library for working with HTML, CSS code (we will use it to search for the information we need in the code)
Create a dollar.py file (you can name it in a different way) and import all the necessary libraries:
You must reply before you can see the hidden data contained here.
You must reply before you can see the hidden data contained here.
You must reply before you can see the hidden data contained here.
You must reply before you can see the hidden data contained here.
You must reply before you can see the hidden data contained here.
You must reply before you can see the hidden data contained here.