ASP crawl Baidu included page number code

Source: Internet
Author: User

ASP crawl Baidu included page number code

<%
Response.Expires =-1
Response.AddHeader "Cache-control", "No-cache"
Response.AddHeader "Pragma", "No-cache"
Wd=request ("D")
If Request ("s") = "Baidus" Then
Baiduurl= "Http://www.baidu.com/s?wd=domain%3A" &wd
Else
Baiduurl= "Http://www.baidu.com/s?wd=site%3A" &wd
End If
Tempstr= Gethttppage (Baiduurl)
Dim baiduwebsite
Set Reg=new Regexp
Reg. Multiline=true
Reg. Global=flase
Reg. Ignorecase=true
Reg. Pattern= "Find the relevant Web page (. | N) *?) Article
Set matches = Reg.execute (TEMPSTR)
For each match1 in matches
Baiduwebsite=match1. Value
Next
Set matches = Nothing
Set reg = Nothing
Baiduwebsite=replace (Baiduwebsite, "Find the relevant page", "")
Baiduwebsite=replace (Baiduwebsite, "article", "")
Baiduwebsite=replace (Baiduwebsite, "about", "")
Baiduwebsite=replace (Baiduwebsite, ",", "")
Baiduwebsite=replace (Baiduwebsite, "", "")

If baiduwebsite= "" Then
If Request ("s") = "Baidus" Then
Response.Write ("document.write" "<a href= ' Http://www.baidu.com/s?wd=domain%3A ' &wd&" ' target= ' _blank ') title= ' data fetch error, please requery later! & #10, lply Studio. COM ' ><font color= #999999 ><b>x</b></font></a> ");")
Else
Response.Write ("document.write" "<a href= ' Http://www.baidu.com/s?wd=site%3A ' &wd&" ' target= ' _blank ') title= ' data fetch error, please requery later! & #10, lply Studio. COM ' ><font color= #999999 ><b>x</b></font></a> ");")
End If
Else
If Request ("s") = "Baidus" Then
Response.Write ("document.write" "<a href= ' Http://www.baidu.com/s?wd=domain%3A ' &wd&" ' target= ' _blank ') Title= ' "&BaiduWebSite&" & #10; " &wd& "' Rel=nofollow class=ln>" &BaiduWebSite& "</a>"); "
Else
Response.Write ("document.write" "<a href= ' Http://www.baidu.com/s?wd=site%3A ' &wd&" ' target= ' _blank ') Title= ' "&BaiduWebSite&" & #10; " &wd& "' Rel=nofollow class=ln>" &BaiduWebSite& "</a>"); "
End If
End If

Function Gethttppage (Path)
t = GetBody (Path)
Gethttppage=bytestobstr (T, "GB2312")
End Function

Function getbody (URL)
        On Error Resume Next
   & nbsp;    Set retrieval = CreateObject ("Microsoft.XMLHTTP")
         with retrieval
       . Open "Get", url, False, "", "
       . Send
        getbody =. Responsebody
        End With
         Set retrieval = Nothing
End Function

Function bytestobstr (body,cset)
        Dim objstream
         Set objstream = Server.CreateObject ("ADO" & "Db.str" & "Eam")
         objstream. Type = 1
        objstream. Mode =3
        objstream. Open
        objstream. Write body
        objstream. Position = 0
        objstream. Type = 2
        objstream. Charset = Cset
        bytestobstr = objstream. ReadText
        objstream. Close
        Set objstream = no
end Function
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.