J
J
Just Python's sheep2020-07-21 20:46:50
Python
Just Python's sheep, 2020-07-21 20:46:50

How to parse span on a website? Or how to remove words from the text, and leave the numbers?

I need to parse the site sinoptik.ru, I need to get data on the minimum temperature, but when I display the text on the screen, there are not only numbers, but also the word "min"
Here is the site code:

<div id="content" class="clearfix"> 
    <div id="blockDays" data-city-id="303014487" class="bd1"> 
     <div class="tabs" id="tabs" style="-ms-touch-action: pan-y;"> 
      <div class="tabs-wrapper"> 
       <div class="tabs-blockMain tabs-blockMain-1 " data-day="1" id="bd1"> 
        <p>Вторник</p> 
        <p class="date">21</p> 
        <p>июля</p> 
        <span class="weatherIco weatherIco-d100"></span> 
        <div class="temperature"> 
         <div class="min">
          мин. 
          <span>+10°</span>
         </div>

How can I access "+10°"?

Second:
If it is impossible to do as in the first example, then how to remove the text from the received text "min.+10°"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-21
@SoreMix

Use bs4 library
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
Find span and get text via .text

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question