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的更多相关文章
随机推荐
- 数据在千万级别上进行全文检索有哪些技术?强大的大数据全文索引解决方案-ClouderaSearch
数据在千万级别上进行全文检索有哪些技术?强大的大数据全文索引解决方案-ClouderaSearch1.lucene (solr, elasticsearch 都是基于它) 2.sphinx3.elas ...
- [转载]ASP.NET中IsPostBack详解
1.IsPostBack介绍Page.IsPostBack是一个标志:当前请求是否第一次打开. 调用方法为:Page.IsPostBack或者IsPostBack或者this.IsPostBack或者 ...
- Low-level Native Plugin Interface
http://docs.manew.com/Manual/index.htm https://docs.unity3d.com/Manual/NativePluginInterface.html ht ...
- Centos下使用php调用shell脚本
我们在实际项目中或许会遇到php调用shell脚本的需求.下面就用简单案例在Centos环境下实践 准备 查看php.ini中配置是否打开安全模式 //php.ini safe_mode = //这个 ...
- 20162311 Hash 补分博客
20162311 Hash 补分博客 一.任务详情 二.解题过程 除留余数法和拉链法都懂了,也都会做,主要是开放寻址法.课下查了一些资料,也问了老师才彻底理解 引用例子 引用网上的一个例子来理解 参考 ...
- bzoj 3223 文艺平衡树 - Splay
3223: Tyvj 1729 文艺平衡树 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 3884 Solved: 2235[Submit][Sta ...
- Msys2的安装,并整合到cmder中
下载:msys2-x86_64-20161025.exe 下载安装包,然后装上. 打开msys的shell之后首先升级一下pacman,然后就可以愉快地Syu了. $ pacman -Sy pacma ...
- [IDEA插件] - 一个不错的插件
今天看到微信平台一篇推送IDEA插件的文章继而下载了个插件看了下. 名字叫做codehelper.generator codehelper.generator http://plugins.jetbr ...
- junit中test注解测试使用案列解析二
本文原创,转载请注明出处 在上文中,已经简单的解析了junit中test注解的使用方法,今天在进行test测试时,遇到了一个异常,于是想深 入的研究一下. 还原一下今天的异常代码: @Service ...
- linux之cut用法--转载
cut是一个选取命令,就是将一段数据经过分析,取出我们想要的.一般来说,选取信息通常是针对“行”来进行分析的,并不是整篇信息分析的. (1)其语法格式为:cut [-bn] [file] 或 cut ...