📄 displaysixdegrees.aspx
字号:
<Script Runat="Server">
Dim objSixDegrees As New SixDegrees
Dim objMatches As New GetLinksMatches
Dim objRandom As New Random
Dim colHistory As New ArrayList
Sub Button_Click( s As Object, e As EventArgs )
objSixDegrees.UserAgent = "SixDegrees"
objSixDegrees.Timeout = 5000
objSixDegrees.AllowAutoRedirect = True
GetNextLink( txtUrl.Text )
dgrdHistory.DataSource = colHistory
dgrdHistory.DataBind()
End Sub
Sub GetNextLink( strCurrentLink )
Dim strNextLink As String
colHistory.Add( strCurrentLink )
objSixDegrees.Url = strCurrentLink
Try
objMatches = objSixDegrees.GetLinks()
Catch ex As Exception
colHistory.Add( ex.Message )
End Try
If Not ( objMatches.Links Is Nothing ) And colHistory.Count < 25 Then
If objRandom.Next( 2 ) = 1 Then
Array.Reverse( objMatches.Links )
End If
For each strNextLink in objMatches.Links
If strNextLink.ToLower() <> strCurrentLink.ToLower() Then
GetNextLink( strNextLink )
Exit For
End If
Next
End If
End Sub
</Script>
<html>
<head><title>DisplaySixDegrees.aspx</title></head>
<body>
<h2>Six Degrees of Separation</h2>
<form runat="Server">
<asp:TextBox
id="txtUrl"
Columns="40"
Text="http://"
Runat="Server" />
<asp:Button
Text="Go!"
OnClick="Button_Click"
Runat="Server"/>
</form>
<p>
<asp:DataList
id="dgrdHistory"
CellPadding="6"
Gridlines="Both"
AlternatingItemStyle-BackColor="lightblue"
Runat="Server">
<ItemTemplate>
<%# Container.ItemIndex %> -
<asp:HyperLink
Text='<%# Container.DataItem %>'
NavigateUrl='<%# Container.DataItem %>'
Runat="Server" />
</ItemTemplate>
</asp:DataList>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -