简体   繁体   English

Excel VBA脚本从预定义的URL列表复制和粘贴数据

[英]Excel VBA Script to Copy and Paste Data from a Predefined List of URLs

I'm pulling my hair out over this. 我正在为此扯头发。 I've seen other topics that almost address this question, but their methods are normally too specific. 我看到了几乎可以解决这个问题的其他主题,但是它们的方法通常过于具体。 I don't need anything as complicated as scraping 我不需要刮刮刀那么复杂的东西

I have about 64,000 URLs in column A of my file. 我的文件A列中有大约64,000个URL。 I want Excel to go to each URL and once it loads, copy the entire page and then paste it into Excel. 我希望Excel转到每个URL,并在加载后复制整个页面,然后将其粘贴到Excel中。 I would like all the pasted data in the same workbook and same sheet pasted one after the other. 我希望所有粘贴的数据都在同一工作簿和同一工作表中一个接一个地粘贴。

Well here's the finished code, if anyone was wondering. 好吧,这是完成的代码,如果有人想知道的话。

    Sub Macro3()
'
' Macro3 Macro
'
'
Dim Erw, Frw, Lrw
Drw = 1
Frw = 1
Lrw = Range("A" & Rows.Count).End(xlUp).Row
For Erw = Frw To Lrw

With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;" & Range("A" & Erw).Value, Destination:=Range("G" & Drw))
        .Name = ""
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "6"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    Drw = Drw + 80
Next Erw

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM