Excel的Google结果数 [英] Number of Google Results from Excel

查看:84
本文介绍了Excel的Google结果数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel中给出一列字符串,是否有一种简单的方法可以从每个字符串的Google搜索中返回结果数量?我正在寻找一种将Excel中的文本数据列表转换为Google搜索结果的方法。

解决方案

想法从这里(但修改):

  Public Sub ExcelGoogleSearch()

Dim searchWords As String

带表格(Sheet1)
RowCount = 1
Do While .Range(A& RowCount)<
searchWords = .Range(A& RowCount).Value

'通过在
之间添加+空格来获取关键字并进行验证searchWords =替换$(searchWords, ,+)

'获取Google-searchterm网页的源代码
search_url =http://www.google.com/search?hl=zh-CN&q =& searchWords& & meta =
设置search_http = CreateObject(MSXML2.XMLHTTP)
search_http.OpenGET,search_url,False
search_http.send
results_var = search_http.responsetext
设置search_http =没有

'查找结果的数量并张贴到
pos_1 = InStr(1,results_var,resultStats>,vbTextCompare)
pos_2 = InStr(3 + pos_1,results_var,>,vbTextCompare)
pos_3 = InStr(pos_2,results_var,< nobr>,vbTextCompare)
NumberofResults = Mid(results_var, 1 + pos_2,(-1 + pos_3 - pos_2))
范围(B& RowCount)= NumberofResults
RowCount = RowCount + 1
循环
结束
End Sub



HTH


Given a column of strings in Excel, is there an easy way to return the number of results from a Google search for each of the strings? I am looking for a way to convert a list of text data from Excel into Google search results.

解决方案

Idea From here (but modified):

Public Sub ExcelGoogleSearch()

Dim searchWords As String

With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) <> ""
searchWords = .Range("A" & RowCount).Value

' Get keywords and validate by adding + for spaces between
searchWords = Replace$(searchWords, " ", "+")

' Obtain the source code for the Google-searchterm webpage
search_url = "http://www.google.com/search?hl=en&q=" & searchWords & "&meta="""
Set search_http = CreateObject("MSXML2.XMLHTTP")
search_http.Open "GET", search_url, False
search_http.send
results_var = search_http.responsetext
Set search_http = Nothing

' Find the number of results and post to sheet
pos_1 = InStr(1, results_var, "resultStats>", vbTextCompare)
pos_2 = InStr(3 + pos_1, results_var, ">", vbTextCompare)
pos_3 = InStr(pos_2, results_var, "<nobr>", vbTextCompare)
NumberofResults = Mid(results_var, 1 + pos_2, (-1 + pos_3 - pos_2))
Range("B" & RowCount) = NumberofResults
RowCount = RowCount + 1
Loop
End With
End Sub

HTH

这篇关于Excel的Google结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆