How to use ASP code to obtain the webpage source code and asp code to obtain the source code

Source: Internet
Author: User

How to use ASP code to obtain the webpage source code and asp code to obtain the source code

When ajax is used, we cannot obtain data from servers that are not our own in cross-origin mode. Therefore, this method is used to obtain data from different servers:

1. Request data from the webpage in the current domain, including a URL

2. The asp code in the webpage of the requested domain requests data from the cross-origin server, and then returns the data to the asp file in the domain.


Code:

123456789101112 Function getHtml (url) 'is backed up in HTML Format    Set xh = CreateObject("Microsoft.XMLHTTP")    xh.Open"GET",url,0    xh.Send()    Set MyStream=CreateObject("Adodb.Stream")    MyStream.Type =2    MyStream.Open    MyStream.WriteText xh.responseText    MyStream.Position =0    getHtml=MyStream.ReadText    MyStream.CloseEnd Function

The above source code is based on the instructions on Microsoft. XMLHTTP objects and Adodb. Stream on the Internet. It is the original code.
How can I easily obtain the ASP source code of a webpage?

Pour cold water first! It won't be easy in any way
What security is there if it is easy to get?
If you really want to, you can try to detect Server Vulnerabilities. If the server is hacked, take the code again.
Or detect asp vulnerabilities (this is feasible), and then download them directly using tools such as asp Trojans.

How does ASP obtain webpage code?

Assume that the database is aaa. mdb, and the table name in the database is bbb. The bbb contains the field id (automatic number), and the url is the movie address. Assume that the database and move. asp are in the same directory as play. asp:
Move. asp code (list all movies in the bbb table, starting from the row of the table ):
<%
'Open the database
ConnStr = "DBQ =" + server. mappath ("aaa. mdb") + "; DefaultDir =; DRIVER = {Microsoft Access Driver (*. mdb )}"
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. open ConnStr
'List all items in the bbb table
Set rs = Server. CreateObject ("ADODB. Recordset ")
SQL = "select * from bbb"
Rs. open SQL, conn, 1, 1
Do while not rs. eof
%>
<Tr>
<Td align = "center" valign = "middle" bgcolor = "#000000"> <span class = "style10 style4"> <a href = "play. asp? Id = <% = rs ("id") %> "> video <% = rs (" id ") %> <a> </span> </td>
</Tr>
<%
Rs. movenext
Loop
Rs. close
Set rs = nothing
Conn. close
Set conn = nothing
%>

Play. asp code (get the corresponding url from the database by passing the id ):
<%
'Open the database
ConnStr = "DBQ =" + server. mappath ("aaa. mdb") + "; DefaultDir =; DRIVER = {Microsoft Access Driver (*. mdb )}"
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. open ConnStr
'Read the selected video URL
Id = request. querystring ("id ")
Set rs = Server. CreateObject ("ADODB. Recordset ")
SQL = "select * from bbb where id =" & id
Rs. open SQL, conn, 1, 1
Url = rs ("url ")
Rs. close
Set rs = nothing
Conn. close
Set conn = nothing
%>
& Lt; object id = rPlayer height = 375 width = 608
Classid = clsid... the remaining full text>

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.