Skip to content

Instantly share code, notes, and snippets.

Alex Lam alexlamazing

  • Hong Kong
Block or report user

Report or block alexlamazing

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View webscrapping.py
# import urllib2 library 用作 query 網頁
import urllib2
# import Beautiful soup 用作 parse 回傳頁面的 html
from bs4 import BeautifulSoup
#import pandas to convert list to data frame
import pandas as pd
import csv
View webscrapping.py
#import pandas to convert list to data frame
import pandas as pd
import csv
# ...
df=pd.DataFrame(A,columns=['PageNo'])
df['No']=B
df['Name']=C
View webscrapping.py
#Generate lists
A=[]
B=[]
C=[]
D=[]
E=[]
for table in right_tables:
for body in table.findAll("tbody"):
for row in body.findAll("tr"):
View webscrapping.py
right_tables=soup.findAll('table', class_='table')
View webscrapping.py
#import Beautiful soup 用作 parse 回傳頁面的 html
from bs4 import BeautifulSoup
# 用 Beautiful soup 來 parse 回傳頁面的 html
soup = BeautifulSoup(page, "html.parser")
View webscraping.py
#import urllib2 library 用作 query 網頁
import urllib2
#指定需要提取資料的頁面
locatefamily = "http://www.locatefamily.com/Street-Lists/Hong-Kong/index-1.html"
#用 urllib2 提取有關頁面的 html
page = urllib2.urlopen(locatefamily)
View decorators.xml
<?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">
View web.xml
<!--**************************** 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>
View FreemarkerConfig.xml
<?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
View web.xml
<!--**************************** 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: -->
You can’t perform that action at this time.