P
P
Pavel Baev2021-11-06 12:45:43
Python
Pavel Baev, 2021-11-06 12:45:43

When parsing does not see the class, what should I do?

from bs4 import BeautifulSoup
import requests

URL = " https://auto.ria.com/car/jeep/ "
HEADERS = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0',
'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_='content-bar ')
print(items)

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

parse()
Here is the code and I will attach the result below with the image: 61864ebaf2c27114817650.jpeg
According to the lesson from YouTube, but since it was filmed a long time ago, the HTML code of the site has changed and there were difficulties with this.
Many thanks to those who help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-06
@Kaiffan

<a>There is no class tag on the sitecontent-bar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question