ThorData - Best Residential Proxy Provider

Python/Perl/Bash Dollar exchange rate parser in Python

K4NITEL

Administrator
Staff member
Admin
Joined
Jun 18, 2022
Messages
43
Hellcoins
♆497
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)
You must reply before you can see the hidden data contained here.
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:
You must reply before you can see the hidden data contained here.
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 must reply before you can see the hidden data contained here.
You also need to know your User Agent first. Just google "my user agent" and copy the string into a variable:
You must reply before you can see the hidden data contained here.
Now we need to get the page code:
You must reply before you can see the hidden data contained here.
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:
You must reply before you can see the hidden data contained here.
Here is the entire parser code:
You must reply before you can see the hidden data contained here.
 
Top