<%
'-----------------------------------------------------------
' Set the global variable strGoogleKey.
'-----------------------------------------------------------
Dim strGoogleKey
strGoogleKey = "insert your key"
'-----------------------------------------------------------
' The function GetResult( ) is the heart of Google Smackdown.
' It queries Google with a given word or phrase and returns
' the estimated total search results for that word or phrase.
' By running this function twice with the two words the user
' enters into the form, we have our Smackdown.
'-----------------------------------------------------------
Function GetResult(term)
'-----------------------------------------------------------
' Set the variable the contains the SOAP request. A SOAP
' software package will generate a similar request to this
' one behind the scenes, but the query for this application
' is very simple so it can be set "by hand."
'-----------------------------------------------------------
strRequest = "<?xml version='1.0' encoding='UTF-8'?>" & vbCrLf & VbCrLf
strRequest = strRequest & "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"""
strReqeust = strRequest & " xmlns:xsi=""http://www.w3.org/1999/XMLSchema-instance"""
strRequest = strReqeust & " xmlns:xsd=""http://www.w3.org/1999/XMLSchema"">" & vbCrLf
strRequest = strRequest & " <SOAP-ENV:Body>" & vbCrLf
strRequest = strRequest & " <ns1:doGoogleSearch xmlns:ns1=""urn:GoogleSearch"""
strRequest = strRequest & " SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" & vbCrLf
strRequest = strRequest & " <key xsi:type=""xsd:string"">" & strGoogleKey & "</key>" & vbCrLf
strRequest = strRequest & " <q xsi:type=""xsd:string"">""" & term & """</q>" & vbCrLf
strRequest = strRequest & " <start xsi:type=""xsd:int"">0</start>" & vbCrLf
strRequest = strRequest & " <maxResults xsi:type=""xsd:int"">1</maxResults>" & vbCrLf
strRequest = strRequest & " <filter xsi:type=""xsd:boolean"">true</filter>" & vbCrLf
strRequest = strRequest & " <restrict xsi:type=""xsd:string""></restrict>" & vbCrLf
strRequest = strRequest & " <safeSearch xsi:type=""xsd:boolean"">false</safeSearch>" & vbCrLf
strRequest = strRequest & " <lr xsi:type=""xsd:string""></lr>" & vbCrLf
strRequest = strRequest & " <ie xsi:type=""xsd:string"">latin1</ie>" & vbCrLf
strRequest = strRequest & " <oe xsi:type=""xsd:string"">latin1</oe>" & vbCrLf
strRequest = strRequest & " </ns1:doGoogleSearch>" & vbCrLf
strRequest = strRequest & " </SOAP-ENV:Body>" & vbCrLf
strRequest = strRequest & "</SOAP-ENV:Envelope>" & vbCrLf
'-----------------------------------------------------------
' The variable strRequest is now set to the SOAP request.
' Now it's sent to Google via HTTP using the Microsoft
' ServerXMLHTTP component.
'
' Create the object...
'-----------------------------------------------------------
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
'-----------------------------------------------------------
' Set the variable strURL equal to the URL for Google Web
' Services.
'-----------------------------------------------------------
strURL = "http://api.google.com/search/beta2"
'-----------------------------------------------------------
' Set the object to open the specified URL as an HTTP POST.
'-----------------------------------------------------------
xmlhttp.Open "POST", strURL, false
'-----------------------------------------------------------
' Set the Content-Type header for the request equal to
' "text/xml" so the server knows we're sending XML.
'-----------------------------------------------------------
xmlhttp.setRequestHeader "Content-Type", "text/xml"
'-----------------------------------------------------------
' Send the XML request created earlier to Google via HTTP.
'-----------------------------------------------------------
xmlhttp.Send(strRequest)
'-----------------------------------------------------------
' Set the object AllItems equal to the XML that Google sends
' back.
'-----------------------------------------------------------
Set AllItems = xmlhttp.responseXML
'-----------------------------------------------------------
' If the parser hit an error--usually due to malformed XML,
' write the error reason to the user. And stop the script.
' Google doesn't send malformed XML, so this code shouldn't
' run.
'-----------------------------------------------------------
If AllItems.parseError.ErrorCode <> 0 Then
response.write "Error: " & AllItems.parseError.reason
response.end
End If
'-----------------------------------------------------------
' Release the ServerXMLHTTP object now that it's no longer
' needed--to free the memory space it was using.
'-----------------------------------------------------------
Set xmlhttp = Nothing
'-----------------------------------------------------------
' Look for <faultstring> element in the XML the google has
' returned. If it exists, Google is letting us know that
' something has gone wrong with the request.
'-----------------------------------------------------------
Set oError = AllItems.selectNodes("//faultstring")
If oError.length > 0 Then
Set oErrorText = AllItems.selectSingleNode("//faultstring")
GetResult = "Error: " & oErrorText.text
Exit Function
End If
'-----------------------------------------------------------
' This is what we're after: the <estimatedTotalResultsCount>
' element in the XML that Google has returned.
'-----------------------------------------------------------
Set oTotal = AllItems.selectSingleNode("//estimatedTotalResultsCount")
GetResult = oTotal.text
Set oTotal = Nothing
End Function
'-----------------------------------------------------------
' Begin the HTML page. This portion of the page is the same
' for both the initial form and results.
'-----------------------------------------------------------
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Google Smackdown</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<h1>Google Smackdown</h1>
This queries Google via its API and receives the estimated total results for each word or
phrase.
<%
'-----------------------------------------------------------
' If the form request items "text1" and "text2" are not
' empty, then the form has been submitted to this page.
'
' It's time to call the GetResult( ) function and see which
' word or phrase wins the Smackdown.
'-----------------------------------------------------------
If request("text1") <> "" AND request("text2") <> "" Then
'-----------------------------------------------------------
' Send the word from the first form field to GetResult( ),
' and it will return the estimated total results.
'-----------------------------------------------------------
intResult1 = GetResult(request("text1"))
'-----------------------------------------------------------
' Check to make sure the first result is an integer. If not,
' Google has returned an error message and the script will
' move on.
'-----------------------------------------------------------
If isNumeric(intResult1) Then
intResult2 = GetResult(request("text2"))
End If
'-----------------------------------------------------------
' Check to make sure the second result is also an integer.
' If they're both numeric, the script can display the
' results.
'-----------------------------------------------------------
If isNumeric(intResult1) AND isNumeric(intResult2) Then
intResult1 = CDbl(intResult1)
intResult2 = CDbl(intResult2)
'-----------------------------------------------------------
' Begin writing the results to the page...
'-----------------------------------------------------------
response.write "<h2>The Results</h2>"
response.write "And the undisputed champion is...<br
没有合适的资源?快使用搜索试试~ 我知道了~
谷歌搜索技巧与谷歌Hack
共70个文件
pl:20个
txt:12个
cgi:8个
4星 · 超过85%的资源 需积分: 10 8 下载量 200 浏览量
2012-03-16
11:42:18
上传
评论
收藏 76KB ZIP 举报
温馨提示
谷歌搜索技巧与谷歌黑客,。众所周知,谷歌的搜索能力世界第一,很多黑客活动都是由谷歌发起。
资源推荐
资源详情
资源评论
收起资源包目录
[GOOGLE.HACKS.探索和利用全球信息资源的技巧和工具].google_hacks_3E_code.zip (70个子文件)
google_hacks_3E_code
hack_87
adwords.pl 1KB
hack_43
.DS_Store 6KB
bookmarklet.txt 657B
hack_89
write_feed.pl 977B
hack_20
goocook.cgi 2KB
I_0596527063_CHP_2_SECT_5_hack20_6.txt 577B
I_0596527063_CHP_2_SECT_5_hack20_5.txt 448B
hack_99
googly.php 988B
hack_92
net_googly.pl 1KB
hack_25
gootopic.cgi 2KB
.DS_Store 15KB
hack_77
gmail_in_python.py 633B
hack_56
goosaver.pl 821B
hack_57
AddGoogleContext.reg 186B
AddToGoogle.html 297B
hack_24
suspect.pl 1KB
hack_29
scattersearch.pl 2KB
hack_27
buzzgle.pl 2KB
hack_19
google_box.pl 1KB
hack_36
news2csv.pl 2KB
hack_23
google_mindshare.cgi 2KB
hack_42
googletech.cgi 2KB
hack_50
GoogleBot.java 2KB
hack_28
google_compare.cgi 5KB
hack_54
GoogleSearch.html 278B
GoogleContext.reg 187B
hack_34
index.php 4KB
hack_40
groups2csv.pl 878B
hack_46
post.php 1KB
hack_26
google_smackdown.txt 12KB
hack_96
GoogleSearchService.cs 1KB
googly.cs 1KB
hack_62
Google Lyric Search.txt 2KB
hack_98
googly.cfm 1KB
hack_44
track_blogs.pl 2KB
hack_4
spell.pl 749B
hack_9
I_0596527063_CHP_1_SECT_19_hack9_1.txt 315B
I_0596527063_CHP_1_SECT_19_hack9_8.txt 968B
I_0596527063_CHP_1_SECT_19_hack9_7.txt 534B
hack_90
googly.pl 1KB
hack_97
GoogleSearchService.vb 1KB
googly.vb 1KB
hack_60
refinesearch.user.js 2KB
hack_93
looply.pl 2KB
hack_68
gmap-contacts.pl 6KB
.DS_Store 6KB
contacts-map.html 2KB
hack_78
securewebmail.usesr.js 308B
hack_67
I_0596527063_CHP_5_SECT_5_hack67_1.txt 760B
hack_21
order_matters.cgi 3KB
hack_61
zoom-google.user.js 10KB
hack_30
mindshare.pl 1KB
hack_59
google-autocomplete.user.js 1KB
hack_32
calc.txt 256B
hack_94
Googly.java 1KB
hack_33
google_feed.pl 2KB
hack_35
grabVideo.pl 2KB
hack_88
I_0596527063_CHP_7_SECT_16_hack88_1.txt 414B
I_0596527063_CHP_7_SECT_16_hack88_2.txt 296B
hack_22
suffixcensus_csv.pl 1KB
suffixcensus.cgi 1KB
hack_52
queryBot.py 2KB
hack_55
google_pdf_edu.src 356B
hack_38
map-news.cgi 5KB
hack_100
googly.vbs 2KB
hack_15
similarimages.user.js 887B
hack_18
.DS_Store 6KB
synonyms.py 968B
hack_95
googly.py 1KB
hack_31
geospider.pl 5KB
共 70 条
- 1
资源评论
- 木千2013-08-06看完后学了不少东西,感谢分享。
tukkkkk
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功