BeautifulSoup or requests not reading some text from div

Question:

I’m new to web scraping and having some trouble getting data from a webpage.

I’m trying to read this web page: https://stroit-kompanii.ru/

and trying to get company`s category and link? but soup get not all ‘title’

import pandas as pd
import requests
import urllib.parse
from bs4 import BeautifulSoup
import time

headers = {
    'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Mobile Safari/537.36'
}

    req = requests.get('https://stroit-kompanii.ru', headers=headers)
    req.encoding = 'cp1251'
    time.sleep(3)
    soup = BeautifulSoup(req.text)
    
    all_cat_list = soup.find_all('div', {'class' :'all_cat_list'})
    print(all_cat_list)

out:

 <a href="polimernaya_poroshko/" title="Поиск строительных компаний в разделе - Полимерная порошковая окраска">Полимерная порошковая окраска</a>
<a href="polistirolbetonnye_b/" title="полистиролбетонные блоки">Полистиролбетонные блоки</a>
<a href="poroshkovye_kraski/" title="Поиск строительных компаний в разделе - Порошковые краски">Порошковые краски</a>
<a href="prodazha_biotualetov/" title="Поиск строительных компаний в разделе - Продажа биотуалетов">Продажа биотуалетов</a>
<a href="prodazha_zemelnyh_uc/" title="Поиск строительных компаний в разделе - Продажа земельных участков, малоэтажных домов">Продаж0      7  5    5  ;  L  =  K  E      C  G  0  A  B  :  &gt;  2  ,         0  ;  &gt;  M  B  0  6  =  K  E      4  &gt;    &gt;  2  /   a   &gt;   
   
   a       t   i   t   l   e   =   "     &gt;  8  A  :      A  B  @  &gt;  8  B  5  ;  L  =  K  E      :  &gt;    ?  0  =  8  9      2      @  0  7  4  5  ;  5      -         @  &gt;  4  0  6  0  ,       0  @  5  =  4  0      =  5  4  2  8  6  8    &gt;  A  B  8      7  0      @  C  1  5  6  &gt;    "       h   r   e   f   =   "   p   r   o   d   a   z   h   a   _   a   r   e   n   d   a   _   n   e   d   v   /   "   &gt;     @  &gt;  4  0  6  0  ,       0  @  5  =  4  0      =  5  4  2  8  6  8    &gt;  A  B  8      7  0      @  C  1  5  6  &gt;    /   a   &gt;   
   
   a       t   i   t   l   e   =   "     &gt;  8  A  :      A  B  @  &gt;  8  B  5  ;  L  =  K  E      :  &gt;    ?  0  =  8  9      2      @  0  7  4  5  ;  5      -         @  &gt;  4  0  6  0  ,         &gt;  =  B  0  6      =  0  B  O  6  =  K  E      ?  &gt;  B  &gt;  ;  :  &gt;  2  "       h   r   e   f   =   "   p   r   o   d   a   z   h   a   _   m   o   n   t   a   z   h   _   n   a   t   /   "   &gt;     @  &gt;  4  0  6  0  ,         &gt;  =  B  0  6      =  0  B  O  6  =  K  E      ?  &gt;  B  &gt;  ;  :  &gt;  2  /   a   &gt;   
   
   a       t   i   t   l   e   =   "     &gt;  8  A  :      A  B  @  &gt;  8  B  5  ;  L  =  K  E      :  &gt;    ?  0  =  8  9      2      @  0  7  4  5  ;  5      -         @  &gt;  4  0  6  0  ,         &gt;  =  B  0  6      ?  &gt;  B  &gt;  ;  :  &gt;  2  "       h   r   e   f   =   "   p   r   o   d   a   z   h   a   _   m   o   n   t   a   z   h   _   p   o   t   /   "   &gt;     @  &gt;  4  0  6  0  ,         &gt;  =  B  0  6      ?  &gt;  B  &gt;  ;  :  &gt;  2  /   a   &gt;   
   

Answers:

import requests
from bs4 import BeautifulSoup
import pandas as pd
r = requests.get('https://stroit-kompanii.ru/')
r.encoding = 'cp1251'
soup = BeautifulSoup(r.text, 'html.parser')

data = [('https://stroit-kompanii.ru/' + x.get('href'), x.text) for x in soup.select_one('div.all_cat_list').select('a')]
df = pd.DataFrame(data, columns = ['Url', 'Category'])
df

This will return a dataframe with all categories and urls from that page section:

Url Category
0   https://stroit-kompanii.ru/avtomatizatsiya_inzh/    Автоматизация инженерных систем
1   https://stroit-kompanii.ru/avtomaticheskie_vor...   Автоматические ворота "Hoermann"
2   https://stroit-kompanii.ru/avtomaticheskie_vor...   Автоматические ворота "ZAIGER"
3   https://stroit-kompanii.ru/avtomaticheskie_voro/    Автоматические ворота, двери
4   https://stroit-kompanii.ru/agentstva_nedvizhimo/    Агентства недвижимости
... ... ...
Answered By: platipus_on_fire
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.