# 读取博客数据
tmp = readLines("http://hi.baidu.com/cloud_wei/blog/item/b26cbfa9b8e601fa1e17a295.html")
start = grep("
",
tmp, fixed = T)
end = grep("
", tmp, fixed = T)
end = end[end > start][1]
x = tmp[start:end]
x = gsub("
", "", x)
x = gsub("<.*>", "", x)
con = textConnection(paste(x, collapse = "\n"))
dat = read.csv(con, strings = F)
dat[, 1] = gsub(" ", "", dat[, 1])
close(con)
library(maps)
library(mapdata)
par(mar = c(2, 1.5, 1.5, 1.5), mgp = rep(0, 3), las = 1,
col.axis = "gray")
map("china", col = "darkgray", ylim = c(18, 54), panel.first = grid())
points(dat$jd, dat$wd, pch = 19, col = rgb(0, 0, 0,
0.5))
text(dat$jd, dat$wd, dat[, 1], cex = 0.9, col = rgb(0,
0, 0, 0.7), pos = c(2, 4, 4, 4, 3, 4, 2, 3, 4, 2, 4, 2, 2,
4, 3, 2, 1, 3, 1, 1, 2, 3, 2, 2, 1, 2, 4, 3, 1, 2, 2, 4,
4, 2))
axis(1, lwd = 0)
axis(2, lwd = 0)
axis(3, lwd = 0)
axis(4, lwd = 0)
# 心意列联表
xinyi = c("一", "二", "三", "四", "五")
n = length(xinyi)
tbl = matrix(nrow = n, ncol = n)
for (i in 1:n) {
for (j in 1:n) {
tmp = readLines(paste("http://www.google.com/search?ie=GB2312&oe=GB2312&q=\"",
xinyi[i], "心", xinyi[j], "意\"", sep = ""))
res = strsplit(tmp[2], "")[[1]][5]
tbl[i, j] = as.integer(gsub(",", "", sub("<.*", "", res)))
}
}
tbl