I am new to django and am taking some information from a web page using lxml. I would like to know how I can display the values on my web page.
import requests
from lxml import html
from django.shortcuts import render
def list_data(request):
return render(request, 'data.html', {})
def get_idhm(url):
page = requests.get(url)
tree = html.fromstring(page.content)
idhm = tree.xpath('//*[@id="responseMunicipios"]/ul/li[6]/div/p[2]/text()')
return idhm[0]
def get_population(url):
page = requests.get(url)
tree = html.fromstring(page.content)
values = tree.xpath('//*[@id="responseMunicipios"]/ul/li[3]/div/p[2]/text()')
return values[0]
this is the view.