Answer the question
In order to leave comments, you need to log in
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:
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question