Answer the question
In order to leave comments, you need to log in
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()
Answer the question
In order to leave comments, you need to log in
Because there is no tag <a>
with class js-hook-isYandexMetricEnabled , where did you get it from?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question