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