python 打开 本地html 文件方法
REF:
https://docs.python-guide.org/scenarios/scrape/
https://www.datacamp.com/community/tutorials/python-xml-elementtree
from lxml import html,etree
import requests
from bs4 import BeautifulSoup
"""
#-----------------------use URL-----------------------------------
base_url = "http://www.runoob.com/"
page = requests.get(base_url)
#page = requests.get('http://econpy.pythonanywhere.com/ex/001.html')
tree = html.fromstring(page.content)
#-----------------------use URL end-----------------------------------
"""
file ='./runoob_cainiao.html'
tree = html.parse(file)
#This will create a list of buyers:
lists = root.xpath('/html/body/div[4]/div/div[2]/div/a/strong/text()')
#print the lists
for list in lists:
print('list: '+ '\n' ,list)