A
A
antinatalismmm2021-01-17 19:35:05
Python
antinatalismmm, 2021-01-17 19:35:05

What is the problem in parsing with Python (BtflSoup + Requests)?

Greetings to all users.

The problem is in the output of data, instead of the answer for the desired class, PyCharm gives out [ ]. What could be the problem? Any class produces the same result.

Actually the code itself and the result on the screen:

import requests
from bs4 import BeautifulSoup

URL = 'https://www.barahla.net/services/220'
HEADERS = {'user-agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'accept': '*/*'}

def get_html(url, params=None):
    r = requests.get(url, headers=HEADERS, params=params)
    return r

def get_content(html):
    soup = BeautifulSoup(html, 'html.parser')
    items = soup.find_all('a', class_='js-hook-isYandexMetricEnabled')
    print(items)

def parse():
    html = get_html(URL)
    if html.status_code == 200:
        get_content(html.text)
    else:
        print('Error')


parse()


600466a7061e4525288818.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-01-17
@SoreMix

Because there is no tag <a>with class js-hook-isYandexMetricEnabled , where did you get it from?

L
LXSTVAYNE, 2021-01-18
@lxstvayne

At you html the page comes with these data?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question