2016-11-28 8 views
0

特定のキーワードがウェブサイト全体に存在するかどうかを知りたい。ウェブサイト全体でキーワードを検索する方法

どうすればいいですか? www.website.com

しかし、私はないです:

クイックグーグルは、ちょうど部位が続く検索用語を入力し... 101)

をグーグルで」

この方法を提案しました

誰でも手助けができますか?

+0

たぶん、あなたのGoogleがあまりにも速かったように電話? http://www.mrexcel.com/forum/excel-questions/277591-vbulletin-macro-search-webpage-text-string.html –

+0

@TimWilkinsonいいえ私はその違いを私が探したいと思っている解決策に気付いていませんでした。 1つのウェブページではなく、サイト全体である。 – newguy

答えて

1

それは基本的にすべてのGoogle検索結果がある場合は、サイト上のキーワードやフレーズを検索することによって確認するためにチェックし、これを試してみてください:

Sub Check_Website() 

Dim ie As Object 
Dim str As String, web As String, URL As String 
Dim iResults As Integer 

'Create IE object 
Set ie = CreateObject("InternetExplorer.Application") 

'Set string to search for 
str = "hello" 
str = Replace(str, " ", "+") 

'Set website to search in 
web = "www.google.com" 

'Create full URL 
URL = "https://www.google.co.uk/search?q=" & str & "+site%3A" & web 

'Navigate to URL 
With ie 
    .Visible = False 
    .Navigate URL 
    Do While .ReadyState <> 4: DoEvents: Loop 
End With 

'Count results on first page 
iResults = ie.Document.getelementsbyclassname("g").Length 

'Message box dependent on results 
If iResults = 0 Then 
    MsgBox "No matches were found." 
Else 
    MsgBox "Matches found." 
End If 

ie.Quit 
Set ie = Nothing 

End Sub 

グーグルが検索結果が意味するために「G」のクラス名を使用しています特定の検索結果ページの "g"クラスで最大10個の項目が表示されます。結果が表示されない場合、カウントされる項目がないことを意味する "g"クラスはありません。また、このような

+0

ありがとうございました:) – newguy

2

何か

Function FIND_IN_PAGE(strURL As String, strSearch As String) 

Dim pos As Long 
Dim ie As SHDocVw.InternetExplorer 
Dim doc As MSHTML.HTMLDocument 

Set ie = New SHDocVw.InternetExplorer 

ie.Visible = 1 
ie.navigate strURL 

Do Until ie.readyState = READYSTATE_COMPLETE And ie.Busy = False 
    DoEvents 
Loop 

Set doc = ie.document.DocumentElement 

pos = InStr(1, doc.innerText, strSearch) 

FIND_IN_PAGE = pos 

ie.Quit 

Set ie = Nothing 
Set doc = Nothing 

End Function 

ので

FIND_IN_PAGE("http://stackoverflow.com/questions/40848321/how-to-search-for-a-keyword-in-entire-website","entire")

関連する問題