Aauto Catching HTTP data

Source: Internet
Author: User

Description : A simple example of crawling the data on a webpage with a racer.

Example : Want to take the data of a website back, and then save in the database inside.

Step : 1, open sql,new A database test, create a new table test.

2. Open the Quick Racer. Prepare to grab the data, take this as an example 3w.nbedi.com/pre_bsq/para/zuanghuogang.asp, I want to take this form of data back.

Import console;        Import Inet.whttp;import web.mshtml;import Sqlserver;var db,err = SQL Server (server= ".";        Database= "Test";        UID = "sa"; Pwd= "123"; ) assert (Db,err), Var http=inet.whttp (), var url= "http://www.nbedi.com/pre_bsq/para/zuanghuogang.asp"; var str= Http.get (URL); Str=string.save ("F:\test.txt", str);  Save to local var str=string.load ("F:\test.txt");  Read var html = web.mshtml ();   Generate parser Html.write (str); Parse the downloaded text var eles = html.queryeles (tagname= "table"); Console.log (eles[1].rows.length); for (I=1;eles[1].rows.length- 1) {var pnamec=eles[1].rows (i). Cells (0). Innertext;var pnamee=eles[1].rows (i). Cells (1). Innertext;var Ccodes=eles[1] . rows (i). Cells (2). Innertext;var pcodes=eles[1].rows (i). Cells (3). Innertext;console.log (Pnamec,pnamee,ccodes, Pcodes);d b.exec ("INSERT into Test (pnamec,pnamee,ccodes,pcodes) VALUES (@pnamec, @pnamee, @ccodes, @pcodes)", {Pnamec =        Pnamec;pnamee = Pnamee;ccodes = Ccodes;pcodes = Pcodes; Write into the database})}console.pause (true);
Ok.


Aauto Catching HTTP data

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.