swj.dk bash linux php python web

lxml

lxml

Test af 'web scraping' vha. et python-script.

#!/usr/bin/python3.6 from lxml import html import requests print("Content-Type: text/html\n\n") page = requests.get('http://econpy.pythonanywhere.com/ex/001.html') tree = html.fromstring(page.content) buyers = tree.xpath('//div[@title="buyer-name"]/text()') prices = tree.xpath('//span[@class="item-price"]/text()') print('Buyers -> ', buyers) print('Prices -> ', prices)

Kilde

Opdateret: 27.01.19