웹페이지 제목을 Excel로 가져오기

웹페이지 제목을 Excel로 가져오기

다른 Excel 셀에 채워진 내용을 기반으로 하이퍼링크를 가져오는 셀을 만들려고 합니다. 하이퍼링크 부분이 작동하고 있지만 웹 페이지나 전체 웹 주소를 가져오는 데 사용하는 ID보다 하이퍼링크에 더 나은 레이블을 갖고 싶습니다. 나는 웹페이지 제목을 가져오는 것이 가장 쉬울 것이라고 생각했습니다. 이것이 가능한가?

조금이나마 도움을 드리고자 현재 이 기능을 사용하여 웹 주소를 가져오고 있습니다.

=IF(LEN(Excel Cell Value)>0,HYPERLINK(CONCATENATE("First part of the web address",(Excel Cell Value),"Second part of the web address"),Excel Cell Value),"")

답변1

=IF(LEN(Excel Cell Value)>0,HYPERLINK(CONCATENATE("First part of the web address",(Excel Cell Value),"Second part of the web address"),Excel Cell Value),"")

나는 이것을 이해하지 못한다. 분해해보도록 할게요 -

If(Len(cell value)>0) - if the cell isn't empty, do TRUE
TRUE - Hyperlink(Concatenate(first, (cell value), second), (cell value)
FALSE - ""

이제 하이퍼링크가 어떻게 작동하는지 살펴보겠습니다.

Hyperlink(link location, friendly name)

당신에게 이것은

link location = concatenate(first, value, second)
friendly name = value

친숙한 이름을 셀 값으로 지정합니다. 따라서 다음과 같은 것이 없으면 -

A1 = Google
A2 = Hyperlink(Concatenate("https://www.",A1,".com",A1))

A2 =Google

이것은 작동하지 않습니다. 당신이 할 수 있는 유일한 일은 VBA를 사용하여 페이지로 이동하여 정보를 수집하거나 다음과 같은 것을 사용하는 것입니다.

A1 = Google
A2 = Searching Website
A3 = Hyperlink(Concatenate("https://www.",A1,".com",A2))

A3 =웹사이트 검색 중


VBA를 통해 제목을 얻으려면 -

Sub gettitle()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "http://superuser.com/"
While ie.busy
 DoEvents
Wend

Dim title As String
title = ie.document.title

MsgBox (title)
End Sub

좋습니다. 함수가 제목과 함께 하이퍼링크를 반환하도록 하려면 UDF(사용자 정의 함수)가 필요합니다.

Function GetTitle(site As Range) As String
Dim title As String
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate site

While ie.busy
 DoEvents
Wend
title = ie.document.title
ie.Quit
GetTitle = title
End Function

그러면 웹페이지 대상으로 이동하여 제목이 반환됩니다. 이제 셀에 웹페이지가 있다고 가정해 보겠습니다 A1. 이제 제목에 대한 함수를 호출해야 합니다.

A2 = GetTitle(A1)
A3 = Hyperlink(A1,A2)

관련 정보