gpt4 book ai didi

vba - 使用 Excel VBA 获取最终 URL

转载 作者:行者123 更新时间:2023-12-04 20:54:17 24 4
gpt4 key购买 nike

我一直在努力解决这个问题,并试图在 StackOverflow 中找到解决方案,但没有任何帮助。

我有数以千计的图片链接(A 列),可以让您访问最终的 JPG 网址。这不是重定向链接,因为我尝试过使用不同的网站但它没有检测到它。

这是一个例子:
https://www.pepperl-fuchs.com/global/en/doci.htm?docilang=ENG&view=showproductpicbypartno&partno=000046

它会带你到这里:
https://files.pepperl-fuchs.com/webcat/navi/productInfo/pd/d428540a.jpg

因此,我想推断 B 列中的所有最终链接。
我找到了一些为每个链接打开 IE 的代码,但它可能错过了复制 URL 并将其粘贴到单元格中的功能:

Sub Test()

Dim IE As Object
Dim URL As Range
Dim objDocument As Object
Dim x As Integer

Set IE = CreateObject("InternetExplorer.Application")

With IE
.Visible = True
For Each URL In Range("A2:A16")
.Navigate URL.Value
While .busy Or .ReadyState <> 4: DoEvents: Wend

If LCase(TypeName(objDocument)) = "htmldocument" Then
Cells(A, 1).Value = objDocument.URL
Cells(A, 2).Value = objDocument.Title
x = x + 1
End If

Next
End With

End Sub

你们能帮我弄清楚缺少什么吗?不幸的是,我对 VBA 并不是很熟悉。

非常感谢

最佳答案

试试这个

Sub Test()

Dim IE As Object
Dim URL As Range
Dim objDocument As Object
Dim x As Integer

Set IE = CreateObject("InternetExplorer.Application")

With IE
.Visible = True

For Each URL In Range("A2:A16")
.Navigate URL.Value
While .busy Or .ReadyState <> 4: DoEvents: Wend

URL.Offset(, 1).Value = .LocationURL
Next
End With

End Sub

关于vba - 使用 Excel VBA 获取最终 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51598219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com