iT邦幫忙

0

Excel VBA 可以練習抓取網路上資料圖片的 URL

  • 分享至 

  • xImage

xcel VBA 可以練習抓取網路上的資料圖片 的 URL

blanksoul12 iT邦研究生 5 級 ‧ 2022-12-06 17:43:08 檢舉
你想問什麼?
player iT邦大師 1 級 ‧ 2022-12-06 18:21:57 檢舉
用Execl裡的VBA跑抓遠端Url的圖檔,另存新擋在本機?
只是有的網站會擋喔
原理一樣是引用【Microsoft HTML Object Library】與【Microsoft Internet Controls】
用法請自己找
有可能需要自行拆解HTML找出圖檔的Url
我找到了 其他類似的 URL of WebSite "https://www.pinterest.com/oxxostudio/outdoor/" 允許存取 請問可以教我 如何抓取圖片 Learn step by step 如同 Excel VBA 的眉眉角角Day29?
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
ahfuyeuem
iT邦研究生 4 級 ‧ 2022-12-07 08:50:02
Private Sub CommandButton1_Click()

Dim picture As String

picture = "http://www.example.com/aaa.jpg"

ActiveSheet.Pictures.Insert(picture)

End Sub
看更多先前的回應...收起先前的回應...

Would you please kindly teach me how to solve the following problems?

Thank you in advance,

VBA CODE:
Sub CommandBunClick()

Dim picture As String

picture = "https://i.pinimg.com/236x/39/eb/1d/39eb1dc594a91c4c1280dcf9d1b1237f.jpg"
ActiveSheet.Pictures.Insert (picture) 'successed
picture = "https://i.pinimg.com/236x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg"
ActiveSheet.Pictures.Insert (picture) 'successed

' picture = "https://i.pinimg.com/236x/39/eb/1d/39eb1dc594a91c4c1280dcf9d1b1237f.jpg 1x"
' Fail 'ActiveSheet.Pictures.Insert (picture)
picture = "https://i.pinimg.com/236x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 1x, https://i.pinimg.com/474x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 2x, https://i.pinimg.com/736x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 3x, https://i.pinimg.com/originals/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.png 4x"
' Fail 'ActiveSheet.Pictures.Insert (picture)

srcSet = "https://i.pinimg.com/236x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 1x, https://i.pinimg.com/474x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 2x, https://i.pinimg.com/736x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 3x, https://i.pinimg.com/originals/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.png 4x"
picture = srcSet

' Fail ' ActiveSheet.Pictures.Insert (picture)

picture = "https://i.pinimg.com/236x/39/eb/1d/39eb1dc594a91c4c1280dcf9d1b1237f.jpg 2x"
' Fail 'ActiveSheet.Pictures.Insert (picture)

picture = "https://i.pinimg.com/236x/39/eb/1d/39eb1dc594a91c4c1280dcf9d1b1237f.jpg 3x"
' Fail 'ctiveSheet.Pictures.Insert (picture)

End Sub

The original code of HTML page:

The original code of HTML page:

**Hi. Ahfuyeuem,

請問此URL,抓圖 : 程式如何寫才能成功抓圖? (不好意思, 麻煩您了)
picture = "https://i.pinimg.com/236x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 1x, https://i.pinimg.com/474x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 2x, https://i.pinimg.com/736x/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.jpg 3x, https://i.pinimg.com/originals/e7/26/d4/e726d4056bd1b77d66399a94c701d5a2.png 4x"
' Fail 'ActiveSheet.Pictures.Insert (picture)

**

我要發表回答

立即登入回答