この記事では、リストページをクロールするバッチのチュートリアル共有を紹介します。以下の詳細なチュートリアルを見てみましょう。それを必要とする友達はそれを参照できます。
一部の人々は、プログラムをrawっているときは宝物ですが、彼らはまだTNDのためにそれらを販売しています。これらの人がいるのは本当に本当です!たぶん、次のことは少し悪いです
以下には、書き込みストアの機能がなく、この点に達しました。エントリ機能は非常に簡単です。必要に応じて自分で完了してください。自分で他の機能を改善してください!コードをコピーして直接実行して効果を確認します
dim url、list_pagecode、array_articleid、i、articlid
dim content_pagecode、content_tempcode
dim content_categoryid、content_categoryName、borderid、classid、bordername、className
Dim Articletitle、articleauthor、Articlom -articlecontent
url = "http://www.webasp.net/article/class/1.htm"
list_pagecode = gethttppage(url)
list_pagecode = regexptext(list_pagecode、 "print"、 "
list_pagecode = regexptext(list_pagecode、 "現在のリストページの記事リンクを取得して分離します
array_articleid = split(list_pagecode "、") 'arrayを作成して記事IDを保存します
i = 0からubound(array_articleid)-1の場合
artureid = array_arrayid(i) 'arrayid
content_pagecode = gethttppage( "http://www.webasp.net/article/"&artured) '記事ページのコンテンツを取得します
'=======================================================
content_tempcode = regexptext(content_pagecode、 "Technical Tutorial >>"、 ">> content"、0)
content_categoryid = regexptext(content_pagecode、 ""、1)
borderid = split(content_categoryid、 "、")(0) 'Big class id
classId = split(content_categoryid、 "、")(1) 'サブクラスID
'=============主要なカテゴリが存在するかどうかを確認してください。 start ==================
「存在しない場合は、データベースを入力します
'============主要なカテゴリが存在するかどうかを確認します=================
'Response.write(borderid& "、"&classid& "
「)
content_categoryName = regexptext(content_pagecode、 "/'>"、 ""、1)
bordername = split(content_categoryName、 "、")(0) '大きなクラス名
className = split(content_categoryName、 "、")(1) 'サブクラス名
'=============サブクラスが存在するかどうかを確認します=================
「存在しない場合は、データベースを入力します
'=============サブクラスが存在するかどうかを確認します=================
'============================================================
'=================================================================
articletitle = regexptext(content_pagecode、 " "、 " "、0)
articleauthor = regexptext(content_pagecode、 "著者:"、 ""、0)
記事from = regexptext(content_pagecode、 "source:"、 ""、0)
articLecontent = regexptext(content_pagecode、 ""、 ""&vbcrlf& ""&vbcrlf& ""、0)
'=====================================================================
Response.write(articletitle& "
「)
Response.flush()
次
いくつかの関数が添付されています。
関数gethttppage(url)if(isobjinstalled( "microsoft.xmlhttp")= false)then
Response.Write "
サーバーはmicrosoft.xmlhttpコンポーネントをサポートしていません」
err.clear
Response.End
ifを終了します
エラーの再開時に次に再開します
dim http
http = server.createobject( "msxml2.xmlhttp")を設定します
http.open "get"、url、false
http.send()
if(http.readystate4)then
出口機能
ifを終了します
gethttppage = bytestobstr(http.responsebody、 "gb2312")
http = Nothingを設定します
if(err.number0)then
Response.Write "
ファイルの内容を取得するときにエラーが発生しました」
'Response.End
err.clear
ifを終了します
エンド関数
function bytestobstr(codebody、codeset)
DIM OBJSTREAM
objstream = server.createObject( "adodb.stream")を設定します
objstream.type = 1
objstream.mode = 3
objstream.open
objstream.write codebody
objstream.position = 0
objstream.type = 2
objstream.charset = codeset
bytestobstr = objstream.readtext
objstream.close
objstream = Nothingを設定します
エンド関数
'==========================================================================
'関数:コンポーネントがインストールされているかどうかを確認します
'返品値:true ----インストール
'false ---インストールされていません
'==========================================================================
function isobjinstalled(objname)
エラーの再開時に次に再開します
isobjinstalled = false
err = 0
dim testobj
set testobj = server.createobject(objname)
if(0 = err)then isobjinstalled = true
testobj =何も設定しません
err = 0
エンド関数
関数regexptext(strng、strstart、strend、n)
Dim Regex、Match、Matches、Retstr
regex = new regexpを設定します
regex.pattern = strstart& "([/s/s]*?)"&strend
regex.ignorecase = true
regex.global = true
一致を設定= regex.execute(strng)
試合の各試合について
if(n = 1)then
retstr = retstr&regex.replace(match.value、 "$ 1")& "、"
それ以外
retstr = retstr&regex.replace(match.value、 "$ 1")
ifを終了します
次
regexptext = retstr
regex = Nothingを設定します
上記は、特定のリストページをクロールするバッチのチュートリアル共有のコンテンツ全体の導入です。編集者によって編集された関連する知識と資料があなたに役立つことを願っています。その他のコンテンツについては、引き続きWuxin TechnologyチャンネルのWebサイトに注意を払います。