读取博客内容

闲来无事,写一段可以读取博客内容的代码。


Dim http As Object
Dim StrText
Dim htmlc, httpText
Dim s
Set http = CreateObject(“Microsoft.xmlhttp”)
‘htmlc = “https://flywow.net/2018/05/%E6%88%91%E7%9A%84%E9%9D%92%E6%98%A5%E6%98%AF%E5%9F%BA%E7%9D%A3/”
htmlc = “https://flywow.net/2015/08/%E5%A6%82%E4%BD%95%E8%BF%B7%E5%A4%B1%E4%BA%86/”
http.Open “get”, htmlc, False
http.send
‘StrText = BytesToBstr(http.responsebody, “GB18030”)
‘StrText = http.responsebody
‘a = Replace(“\xa0”, “”, http.responsebody)
‘StrText = StrConv(a, vbUnicode)
‘StrText = StrConv(http.responsebody, vbUnicode, &H404) ‘获得网页源代码,且转换成Big5码
StrText = StrConv(http.responsebody, vbUnicode, &H804) ‘获得网页源代码,且转换成GBK码
‘StrText = StrConv(http.responsebody, vbUnicode, uft – 8)
‘ThisWorkbook.Sheets(“网页”).Range(“A1”) = StrText
httpText = http.responsetext
ThisWorkbook.Sheets(“网页”).Range(“A1”) = httpText
gjz1 = [C1] ‘其内容为:<div class= “entry-content clearfix” >
d = Split(Split(httpText, gjz1)(1), “共享此文章:”)(0) ‘限定文章部分
[A1] = d
‘d = Right(d, (Len(d) – InStr(1, d, “</a>”, vbTextCompare) – 3))
e = “”
i = 0
Do While InStr(d, “<“) > 0
i = i + 1
‘[B1] = i
s = Split(d, “<“)(0)
e = e & s
‘[A1] = e
l = Right(d, Len(d) – Len(s) – 1)
‘[A2] = l
g = Split(l, “>”)(0)
d = Right(l, Len(l) – Len(g) – 1)

Loop

d = e & d
[D1] = d
MsgBox “OK!”, 64

Leave a Reply

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

希望和绝望

最新文章

归档
分类

打赏

可长按保存图片至本地后进行二维码识别。

若在微信内打开,也可以通过“跳转至公账号打赏“。

若想获取内容推送,请留下电子邮件。

(需要邮件验证确定)

内容推送订阅