Parse HTML is required

[ <div style="width: 40%;/* float: left; */">2.19</div>, <div style="width: 40%;/* float: left; */">2.49</div>, <divstyle="width: 40%;/* float: left; */">2.59</div>, <div style="width: 40%;/* float: left; */">2.64</div>, <div style="width: 40%;/* float: left; */">2.43</div>, <div style="width: 40%;/* float: left; */">2.63</div>, <div style="width: 40%;/* float: left; */">2.58</div>, <div style="width: 40%;/* float: left; */">2.39</div>, <div style="width: 40%;/* float: left; */">2.49</div>, <div style="width: 40%;/* float: left; */">2.36</div>, <div style="width:40%;/* float: left; */">2.41</div>, <div style="width: 40%;/* float: left; */">2.59</div> ] 

So, to get values ​​between divs (2.19 [...] 2.49)

UPD: Added code for loading HTML page.

Bringing the code to simplicity comes out like this

 from bs4 import BeautifulSoup import requests r = requests.get('https://taripebi.ge/%E1%83%91%E1%83%94%E1%83%9C%E1%83%96%E1%83%98%E1%83%9C%E1%83%98%E1%83%A1-%E1%83%A4%E1%83%90%E1%83%A1%E1%83%94%E1%83%91%E1%83%98') scraping_html = BeautifulSoup(r.text, 'html.parser') find_by_attr = scraping_html.find_all('div', attrs={'style':'width: 40%;/* float: left; */'}) print(find_by_attr) 
  • one
    If everything is so simple for you, then you can use regexps (re module). But in general, this approach is wrong. There are modules that allow parsing the entire html-page entirely, without intermediate elements, as in the question. You already know about BeautifulSoup, so use it in full - Sergey Nudnov
  • one
    I understand that the list was obtained using bs4? If I were you, I would bring in a piece of the source html file, a piece of code from bs4 that receives the list, and asked how to improve this code - Sergey Nudnov 7:14 pm
  • Updated and added to the question a simplified code without decorators, comments and notes. - Qualcomm Atheros
  • Ok, I can't check it myself, try adding .text at the end of the find_all() call. How here - Sergey Nudnov
  • Heck. All ingenious is simple. The truth is there at the output gives a list and you need to run through the cycle, and everything works. Thank you very much. - Qualcomm Atheros

1 answer 1

Figures were received after the answer @ sergey-nudnov

It was enough to run through the loop and add .text

 for item in find_by_attr: print(item.text) 
  • Fine. Propted :) - Sergey Nudnov am