Skip to content
Advertisement

python beautifulsoup duplicating results

I’m trying to learn beatifulsoup (and python as a whole, pretty much still a beginner) and playing around with how to use it properly. I notice that when I scrape the website I’m testing for data from the search results, it lists it 3 times.

Specifically, I’m trying to output the title, link, and price of the real estate property from the website. The price doesn’t seem to duplicate while the title and link does. Can’t really figure out if it’s because of my code or something with the website itself.

JavaScript

Output would be something like this where the price doesn’t match the listing because of the duplicated info:

JavaScript

Advertisement

Answer

You should iterate row-by-row. It’s safer than using zip().

To get all titles, links + prices you can use next example:

JavaScript

Prints:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement