Create simple scrape / beautiful soup?


#1

Hi,

I am very new to coding, and I am trying to create a simple scraping tool that allows me to get two parameters from a website. I want to get the price, and the square footage.

One example of what I am trying to get is here: https://www.olx.ro/oferta/titulescu-metrou-basarab-vanzare-cladire-706-mp-IDboupC.html#a37b447ef7

The price is under “Pret vanzare”

and the area is under “Suprafata utila”
(the green boxes that I have in this screenshot here) https://imgur.com/py5Btaw

Any ideas how I can go about it?


#2

This is not an easy thing to do if you are new to coding.
Also its not an easy thing to explain since alot of stuff is happening while scraping a website.

You might want to watch/read a tutorial about this topic.
Here is a link to a tutorial that explains how to apply web-scraping using python.

Hope it helps.


#3

Hey Biirra,

This was great help, thanks. I followed the steps, and created the following code in a text editor. When I run it on my Terminal I get a bunch of errors that look like this: name_box = soup.find(‘div’, attrs={‘price’: ‘label’})
-bash: syntax error near unexpected token `(’

This is the line of code I created based off the tutorial:

import urllib2
from bs4 import BeautifulSoup

quote_page = ‘https://www.olx.ro/oferta/inchiriez-spatiu-comercial-in-vlaicu-ID8Hlvr.html#9f6b52bcc1;promoted

page = urllib2.urlopen(quote_page)

soup = BeautifulSoup(page, ‘html.parser’)

name_box = soup.find(‘div’, attrs={‘price’: ‘label’})

name_box = soup.find(‘th’, attrs={‘suprafata’: ‘utila’})


#5

Sorry, i can’t help with this. I myself haven’t done any kind of scraping nor did i follow the tutorial. I just posted it to get you on the right path.

The error says: syntax error near unexpected token(’`

this probably means there is a ( not on the right place. The code you provided does not show this error so it must be somewhere else.

Useally if you put the error in google you will get very close related answers.
(This is kinda the first rule of programming “Google is your friend”)