aauto抓http資料

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   ar   for   strong   sp   

說明:利用快手抓取網頁上面的資料的簡單例子。

例子:想把某網站的資料抓回來,然後儲存在資料庫裡邊。

步驟:1、開啟sql,new一個資料庫Test,建立一個表test。

2、開啟快手。準備抓資料,以這個為例3w.nbedi.com/pre_bsq/para/zuanghuogang.asp,我要把這個表格的資料抓回來。

import console; import inet.whttp;import web.mshtml;import sqlServer;var db,err  = sqlServer(         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); //儲存到本地var str=string.load("f:\test.txt");  //讀取var html = web.mshtml();  //產生解析器html.write(str);   //解析下載的文本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);db.exec( "INSERT INTO test(pnamec,pnamee,ccodes,pcodes) VALUES(@pnamec,@pnamee,@ccodes,@pcodes)",{pnamec = pnamec;pnamee = pnamee;ccodes = ccodes;pcodes = pcodes;        //寫進資料庫})}console.pause(true);
ok。


aauto抓http資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.