如何抓取该网页中的表格内容?

ceo7288 2005-12-05 10:01:49
抓取网址如下:http://hk.job1998.com/cn/company_detail-Company_Id=3539.html

问题:如何抓取页面中公司名称、电话、传真等信息?

我用这种方法去抓取,可是报错,请大家帮忙!

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift-JIS">
<%
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
'Http.open "GET",url,false
Http.open "POST",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
'getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
getHTTPPage=bytesToBSTR(Http.responseBody,"Shift-JIS")
set http=nothing
if err.number<>0 then
err.Clear
end if
end function

Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing

End Function

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=Len(wstr)
End Function
%>
<title></title>
</head>
<body>
<%
Dim Url,Html
Url= "http://hk.job1998.com/cn/company_detail-Company_Id=3539.html"
Html = getHTTPPage(Url)
start=Newstring(Html,"公司名称:</td><td colspan=""2""><b>")
over=Newstring(Html,"</b></td>")
bodytext=mid(Html,start,over-start)
Response.write bodytext
%>
</body>
</html>
...全文
233 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
你先把整个网页取出来,不要提取table先试试,如果可以的话,做个hta去分析一下,这样一步步来
bflovesnow 2005-12-05
  • 打赏
  • 举报
回复
编码问题?
ceo7288 2005-12-05
  • 打赏
  • 举报
回复
改成这样了,可是什么也不显示啊?

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
'Http.open "POST",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
'getHTTPPage=bytesToBSTR(Http.responseBody,"Shift-JIS")
set http=nothing
if err.number<>0 then
err.Clear
end if
end function

Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing

End Function

Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=Len(wstr)
End Function
%>
<title></title>
</head>
<body>
<%
Dim Url,Html
Url= "http://hk.job1998.com/cn/company_detail-Company_Id=3539.html"
Html = getHTTPPage(Url)
start=Newstring(Html,"公司名称:</td><td colspan=""2""><b>")
over=Newstring(Html,"</b></td>")
bodytext=mid(Html,start,over)
'bodytext=mid(Html,start,over-start)
Response.write bodytext
%>
</body>
</html>
tigerwen01 2005-12-05
  • 打赏
  • 举报
回复
try:
bodytext=mid(Html,start,over)
荣之梦 2005-12-05
  • 打赏
  • 举报
回复

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧