Skip to content

BeautifulSoup price extraction #16

@clixx-io

Description

@clixx-io

This is rough code, but it seems to work for getting prices. Something like this should be in the API if it isn't already.

-# import libraries
import urllib2
from bs4 import BeautifulSoup

-# specify the url
quote_page = "https://www.coinspot.com.au/buy/dgb"

-# query the website and return the html to the variable page
hdr = {'User-Agent': 'Mozilla/5.0'}
req = urllib2.Request(quote_page,headers=hdr)
page = urllib2.urlopen(req)

-# parse the html using beautiful soup and store in variable soup
soup = BeautifulSoup(page, "html.parser")

-# Take out the

of name and get its value
name_box = soup.find('h1', attrs={'class': 'price-title'})

-# strip() is used to remove starting and trailing
name = name_box.text.strip()
print name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions