M
M
Mom's Programmer2020-07-01 12:26:32
Python
Mom's Programmer, 2020-07-01 12:26:32

Python parser not working, what's wrong?

Here is the code

def parse():
  URL = 'https://www.olx.ua/list/'
  HEADERS = {
     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'
  }

  response = requests.get(URL,
  headers = HEADERS)
  soup = BeautifulSoup(response.content, 'html.parser')
  items = soup.findAll('div', class_ = 'offer-wrapper cc_cursor')
  comps = []

  for item in items:
    comps.append({
    'title': item.find('a', class_ = 'marginright5 link linkWithHash detailsLink').get_text(strip = True)
    })

  for comp in comps:
    print(comp['title'])


Here is the result:
5efc56869357c119472225.png

Just spaces without anything, waiting for your help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alan Gibizov, 2020-07-01
@Ekaterina_kuzkova

I suppose the point is that it
class_ = 'offer-wrapper cc_cursor'
is missing in the resulting page.
And cc_cursorit doesn't show up at all.
Try class_ = 'offer-wrapper',what happens?

G
GitCat, 2020-07-01
@GitCat

Did you run the function?) Most likely nothing is output to the console, because you just created the function, but did not run it.
Also, if this is all the code that you wrote, then you need to import the libraries at the beginning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question