GetTitleAndUrl
Sub GetTitleAndUrl()
Dim strText As String
Dim i As Long
Dim OneA
Dim IsContent As Boolean
Dim PageIndex As Long
Dim URL As String
For PageIndex = 1 To 10
URL = "http://blog.sina.com.cn/s/articlelist_1511572751_0_" & PageIndex & ".html" With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
strText = .responsetext
End With Dim arr() As String
ReDim arr(1 To 2, 1 To 1) As String With CreateObject("htmlfile")
.write strText
i = 0
For Each OneA In .getElementsByTagName("a") s = OneA.href If s Like "*http://blog.sina.com.cn/s/blog_*" Then i = i + 1
ReDim Preserve arr(1 To 2, 1 To i) arr(1, i) = OneA.innerhtml
arr(2, i) = s End If
Next
End With With Sheets("标题")
endrow = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row + 1
Set Rng = .Cells(endrow, 1)
Set Rng = Rng.Resize(UBound(arr, 2), UBound(arr))
Rng.Value = Application.WorksheetFunction.Transpose(arr)
End With Next PageIndex End Sub Sub TestRegReplace()
s = "215MY"
s = RegReplace(s, "[A-Z]")
Debug.Print s
End Sub
Public Function RegReplace(ByVal OrgText As String, ByVal Pattern As String, Optional RepStr As String = "") As String
'传递参数 :原字符串, 匹配模式 ,替换字符
Dim Regex As Object
Dim newText As String
Set Regex = CreateObject("VBScript.RegExp")
With Regex
.Global = True
.Pattern = Pattern
End With
newText = Regex.Replace(OrgText, RepStr)
RegReplace = newText
Set Regex = Nothing
End Function Public Function RegTest(ByVal OrgText As String, ByVal Pattern As String) As Boolean
'传递参数 :原字符串, 匹配模式
Dim Regex As Object
Set Regex = CreateObject("VBScript.RegExp")
With Regex
.Global = True
.Pattern = Pattern
End With
RegTest = Regex.TEST(OrgText)
Set Regex = Nothing
End Function Sub dd()
Debug.Print RegTest("13.", "^\d+?.$")
End Sub
GetTitleAndUrl的更多相关文章
随机推荐
- Open-Falcon
A Distributed and High-Performance Monitoring System Scalability Scalable monitoring system is neces ...
- jsonp 方式处理跨域前后端代码如何配合?
JSONP(JSON with Padding)(json 数据填充)只支持GET请求 是JSON的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题. 跨域产生原因是浏览器的同源策略.( ...
- ajax 拦截器设置请求头
使用vue-resource时,往headers里添加token后,post方法会自动变成options? Vue.http.interceptors.push(function(request, n ...
- Linux基础命令---head
head 显示文件开头的几行,默认显示10行,可以使用选项-n来指定行数.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法 ...
- Docker 的 Web 管理工具 DockerFly
Dockerfly是基于 Docker1.12+ (Docker API 1.24+) 开发出Docker 管理工具,提供里最基本的基于 Docker 的管理功能,目的是能够方便广大Docker初学者 ...
- 解析分布式锁之Zookeeper实现(一)
实现分布式锁目前有三种流行方案,分别为基于数据库.Redis.Zookeeper的方案,本文主要阐述基于Zookeeper的分布式锁,其他两种会在后文中一起探讨.现在我们来看下使用Zookeeper如 ...
- SNMP学习笔记之SNMPv3报文认证和加密
下面主要的内容就是SNMPv3的加密和认证过程! USM的定义为实现以下功能: 鉴别 数据加密 密钥管理 时钟同步化 避免延时和重播攻击 1.UsmSecurityParameters(安全参数) 安 ...
- Jquery 给Js动态新添加的元素 绑定的点击事件
//one $('.class').on("click",function(){ alert('one') }); //相当于$('.class').bind("clic ...
- LOJ10066 新的开始
LOJ10066 新的开始 prim 典型题.碰到这种情况,只要建一个虚拟节点,和其他的点连边,按题目给权值即可 代码中把n+1当成虚拟节点 懒得写kruskal就用prim了 #include< ...
- 根据wsdl,基于wsimport生成代码的客户端
根据wsdl,基于wsimport生成代码的客户端 wsimport是jdk自带的命令,可以根据wsdl文档生成客户端中间代码,基于生成的代码编写客户端,可以省很多麻烦. 局限性:wsimport ...