注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

零售创新,创新那些事儿,SPSS,VBA

零售创新

 
 
 

日志

 
 
关于我

新浪微博,零售创新 研究经理,数据分析师 希望和市场研究和零售业的同事共同进步! 本博客发表的都是免费或试用的资料,如果有版权问题请发邮件wangli12a@163.com联系删除。 spss excel vba blog

网易考拉推荐

导入网页数据 VBA  

2012-04-10 09:41:09|  分类: VB和VBA知识 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Option Explicit
Sub a()
    Dim ie1 As Object, dmt As Object, r As Object, i As Long, url(1) As String, j As Long, p%
    'Load UserForm1
    'UserForm1.Show 0
    Set ie1 = UserForm1.WebBrowser1
    url(0) = "http://www.shdjt.com/sh.asp"
    url(1) = "http://www.shdjt.com/sz.asp"
    For p = 1 To 2
        Worksheets(p).[a1].CurrentRegion.Clear
        Worksheets(p).Cells.NumberFormat = "@"
        With ie1
            .Navigate url(p - 1)
            Do Until .ReadyState = 4 And .Busy = False
                DoEvents
            Loop
            Set dmt = .Document
        End With
        Set r = dmt.All.tags("table")(11).Rows
        For i = 0 To r.Length - 1
            For j = 0 To r(i).Cells.Length - 1
                Worksheets(p).Cells(i + 1, j + 1) = r(i).Cells(j).innerText
            Next
        Next
        Set dmt = Nothing
        Set r = Nothing
        Worksheets(p).Range("n1").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Worksheets(p).Rows("2:2").Delete Shift:=xlUp
        Worksheets(p).Range("m1").Value = "ddx10(次)"
        Worksheets(p).Range("n1").Value = "ddx10(连)"
        Worksheets(p).[a1].CurrentRegion.Columns.AutoFit
    Next
    Set ie1 = Nothing
End Sub

 

 

 

真糊涂,忘说了。对不起,www.shdjt.com
Sub test()
Dim myQuery
With ActiveSheet
.Cells.Delete
.[a1] = "Conneting, Please Wait..."
Set myQuery = ActiveSheet.QueryTables _
.Add(Connection:="URL;http://www.shdjt.com", _
Destination:=.Cells(1, 1))
End With
With myQuery
.Refresh
End With
End Sub

 

 

Sub 散户大家庭()
Dim ie As Object, dmt As Object, r As Object, i As Long, url(1) As String, j As Long, p%
Set ie = CreateObject("internetexplorer.application")
[a1].CurrentRegion.Clear
Cells.NumberFormat = "@"
With ie
.Navigate "www.shdjt.com"
Do Until .ReadyState = 4 And .Busy = False
DoEvents
Loop
End With
Set r = ie.Document.All.tags("table")(11).Rows
For i = 0 To 101
For j = 0 To r(i).Cells.Length - 1
Cells(i + 1, j + 1) = r(i).Cells(j).innerText
Next
Next
Set dmt = Nothing
Set r = Nothing
Cells.Font.Size = 9
Columns("E:E").Replace What:=" 点评", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows
Range("n1").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Rows("2:2").Delete Shift:=xlUp
Range("m1").Value = "ddx10(次)"
Range("n1").Value = "ddx10(连)"
[a1].CurrentRegion.Columns.AutoFit
ie.Quit
Set ie = Nothing
End Sub

  评论这张
 
阅读(1305)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017