Skip to content

Instantly share code, notes, and snippets.

View alexlamazing's full-sized avatar

alexlamazing alexlamazing

View GitHub Profile
<html>
<body>
<p>Hello ${name}! You have the following messages:
<#list messages as m>
<p><b>${m.from}:</b> ${m.body}</p>
</#list>
</p>
</body>
</html>
<html>
<body>
<p>Hello Joe! You have the following messages:
<p><b>Tim:</b> Please don't forget to bring the conference papers!</p>
<p><b>Cindy:</b> Can you give me a visit this afternoon?</p>
<p><b>Richard:</b> Don't forget the papers this time!</p>
</p>
</body>
</html>
<!--**************************** Freemarker ************************************ -->
<servlet>
<servlet-name>freemarker</servlet-name>
<servlet-class>freemarker.ext.servlet.FreemarkerServlet</servlet-class>
<!--
Init-param documentation:
http://freemarker.org/docs/api/freemarker/ext/servlet/FreemarkerServlet.html
-->
<!-- FreemarkerServlet settings: -->
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
<!--**************************** Sitemesh ************************************ -->
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/decorators">
<decorator name="main3" page="main3.dec">
<pattern>/updatefood.htm</pattern>
<pattern>/updatefood0.htm</pattern>
</decorator>
<decorator name="main2" page="main2.dec">
<pattern>/addfood.htm</pattern>
</decorator>
<decorator name="main" page="main.dec">
#import urllib2 library 用作 query 網頁
import urllib2
#指定需要提取資料的頁面
locatefamily = "http://www.locatefamily.com/Street-Lists/Hong-Kong/index-1.html"
#用 urllib2 提取有關頁面的 html
page = urllib2.urlopen(locatefamily)
#import Beautiful soup 用作 parse 回傳頁面的 html
from bs4 import BeautifulSoup
# 用 Beautiful soup 來 parse 回傳頁面的 html
soup = BeautifulSoup(page, "html.parser")
right_tables=soup.findAll('table', class_='table')
#Generate lists
A=[]
B=[]
C=[]
D=[]
E=[]
for table in right_tables:
for body in table.findAll("tbody"):
for row in body.findAll("tr"):