Answer the question
In order to leave comments, you need to log in
An error in the parser code, what is the error?
I'm just starting to get acquainted with python, I did everything according to the example, tell me how to correctly determine the 'title'
from bs4 import BeautifulSoup
import requests
def parse():
URL = ''
HEADERS = {
''
}
response = requests.get(URL, headers = HEADERS)
soup = BeautifulSoup(response.content, 'html.parser')
items = soup.findAll('div', class_ = 'offer-wrapper')
comps = []
for item in items:
comps.append({
'tittle' : item.find('a', class_ = 'marginright5 link linkWithHash detailsLink linkWithHashPromoted').get_text(strip = True)
})
for comp in comps:
print(comp['title'])
parse()
Answer the question
In order to leave comments, you need to log in
item.find('a', class_ = 'marginright5 link linkWithHash detailsLink linkWithHashPromoted').get_text(strip = True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question