Introduction to ASP program for automatic collection and warehouse receiving

Source: Internet
Author: User
<%
'Declare the function for obtaining the target information and implement it through the XML component.
Function geturl (URL)
Set retrieval = Createobject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "get", URL, false
. Send
Geturl = bytes2bstr (. responsebody)
'Verify the obtained information. If the length of the information is smaller than 100, the interception fails.
If Len (. responsebody) <100 then
Response. Write "failed to get the remote file <a href =" & URL & "target = _ blank>" & URL & "</a>. "
Response. End
End if
End
Set retrieval = nothing
End Function

'Binary to string, otherwise garbled!
Function bytes2bstr (VIN)
Strreturn = ""
For I = 1 to lenb (VIN)
Thischarcode = ASCB (midb (Vin, I, 1 ))
If thischarcode <& h80 then
Strreturn = strreturn & CHR (thischarcode)
Else
Nextcharcode = ASCB (midb (VIN, I + 1, 1 ))
Strreturn = strreturn & CHR (clng (thischarcode) * & h100 + CINT (nextcharcode ))
I = I + 1
End if
Next
Bytes2bstr = strreturn
End Function

'Specifies the screenshot format, starting from start and ending with last.
Function getkey (HTML, start, last)
Filearray = Split (HTML, start)
Filearray2 = Split (filearray (1), last)
Getkey = filearray2 (0)
End Function

Dim softid, URL, HTML, title
'Get the ID of the page to be retrieved
Softid = request ("ID ")
Url = "http://www3.skycn.com/soft/" & softid & ". html"
Html = geturl (URL)
'Use the software name used to capture the sky as an Example
Title = getkey (HTML, "<font color = '#004fc6 'size = '3'> ", "</font> </B> </TD> </tr> ")

'Open the database and prepare to import data to the database.
dim connstr, Conn, RS, SQL
connstr = "DBQ =" + server. mappath ("db1.mdb") + "; defaultdir =; driver = {Microsoft Access Driver (*. MDB)}; "
set conn = server. createobject ("ADODB. connection ")
Conn. open connstr
set rs = server. createobject ("ADODB. recordset ")
SQL =" select [column name] from [Table name] Where [column name] = '"& Title &"' "
Rs. open SQL, Conn, 3, 3
If RS. EOF and Rs. bof then
RS ("column name") = title
Rs. UPDA Te
set rs = nothing
end if
set rs = nothing
response. Write "collection is complete! "
%>

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.