@@ -0,0 +1,1030 @@
+#-*-coding:UTF-8 -*-%0A# %E4%BD%BF%E7%94%A8 BeautifulSoup 4 parser %E7%B6%B2%E9%A0%81%0A# https://www.crummy.com/software/BeautifulSoup/#Download%0A# https://www.crummy.com/software/BeautifulSoup/bs4/doc/%0Afrom bs4 import BeautifulSoup%0Aimport urllib2%0A%0A# https://gas.goodlife.tw/%0Aurl = %22https://gas.goodlife.tw/%22%0Ahdr = %7B'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',%0A       'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',%0A       'Accept-Charset': 'utf-8,ISO-8859-1;q=0.7,*;q=0.3',%0A       'Accept-Encoding': 'none',%0A       'Accept-Language': 'en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4',%0A       'Connection': 'keep-alive'%7D%0Areq = urllib2.Request(url, headers=hdr)%0Aresponse = urllib2.urlopen(req)%0Ahtml = response.read()%0A#print(html)%0A#parser.feed(html)%0Asoup = BeautifulSoup(html, 'html.parser')%0Aprint(%22==== start ====%22)%0Afor element in soup.find_all('div',id=%22gas-price%22):%0A%09for item in element.find_all('h2'):%0A%09%09print(item.get_text().strip())%09%09%0Aprint(%22==== end ====%22)

add parser by using BS4