delphi7 读取网页内容的问题

miceyou 2012-07-22 09:48:12
我用idhttp读取 http://www.t7online.com/China/Chengdu.htm 网页上的源代码,感觉网页上有很多版块,我只读到主版块,我该如何读取其他版块上“7天”链接上的网页地址,因为链接的网页地址每天都是随机的。
...全文
299 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
miceyou 2012-07-29
  • 打赏
  • 举报
回复
太感谢jiajiajing6了,昨晚弄了一晚 已经做好了,谢谢!
jiajiajing6 2012-07-28
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
重新发下。。 那样看效果不好。。

Delphi(Pascal) code


fhttp.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS124342; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR ……
[/Quote]

fhttp.Get('http://www.t7online.com/China/Chengdu.htm',stream);
改为
str:= fhttp.Get('http://www.t7online.com/China/Chengdu.htm');
就可以了。。。
jiajiajing6 2012-07-28
  • 打赏
  • 举报
回复
重新发下。。 那样看效果不好。。

fhttp.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS124342; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)';
fhttp.Get('http://www.t7online.com/China/Chengdu.htm',stream);
//得到/cgi-bin/region?PRG=citybild&CONT=cncn&CREG=hkch&WMO=56294&LAND=CI&LANG=cn

fhttp.Request.Referer:= 'http://www.t7online.com/China/Chengdu.htm';
str:= fhttp.Get('http://www.t7online.com/cgi-bin/region?PRG=citybild&CONT=cncn&CREG=hkch&WMO=56294&LAND=CI&LANG=cn');
//得到/cgi-bin/citybild?WMO=56294&LANG=cn&BKM=Sichuan/Chengdu&SID=b
//在这个URL后边加上 '#citydetail_window' 就是你想要的路径

str:= fhttp.Get('http://www.t7online.com/cgi-bin/citybild?WMO=56294&LANG=cn&BKM=Sichuan/Chengdu&SID=b'+ '#citydetail_window');



jiajiajing6 2012-07-28
  • 打赏
  • 举报
回复
fhttp.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; BTRS124342; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)';
fhttp.Get('http://www.t7online.com/China/Chengdu.htm',stream);
//得到/cgi-bin/region?PRG=citybild&CONT=cncn&CREG=hkch&WMO=56294&LAND=CI&LANG=cn

fhttp.Request.Referer:= 'http://www.t7online.com/China/Chengdu.htm';
str:= fhttp.Get('http://www.t7online.com/cgi-bin/region?PRG=citybild&CONT=cncn&CREG=hkch&WMO=56294&LAND=CI&LANG=cn');
//得到/cgi-bin/citybild?WMO=56294&LANG=cn&BKM=Sichuan/Chengdu&SID=b
//在这个URL后边加上 '#citydetail_window' 就是你想要的路径

str:= fhttp.Get('http://www.t7online.com/cgi-bin/citybild?WMO=56294&LANG=cn&BKM=Sichuan/Chengdu&SID=b'+ '#citydetail_window');

//这里就得到你所需要的页面容了。。 这个地址是固定的吧。 应该不是动态变的
Frank.WU 2012-07-27
  • 打赏
  • 举报
回复
何必呢。。。
http://weather.xcyh.org/
各种格式,自己喜欢看着办。。。
miceyou 2012-07-25
  • 打赏
  • 举报
回复
我试了 把每个地址都显示了一下,但是没有我要的那个, 因为‘7天’链接的网址每天是随机,所以只有想办法通过主页来读,但是就是找不到。 求高人指点。
下面是显示出来的代码
<link rel="canonical" href="http://www.t7online.com/China/Chengdu.htm">
</head>
<frameset cols="10,800,*" border="0" frameborder="0" framespacing="0">
<frame src="http://wodas.t7online.com/static/wo_leftsky.htm" name="cntlinks" noresize scrolling="no" marginwidth="0" marginheight="0">
<frameset rows="90,30,*" border="0" frameborder="0" framespacing="0">
<frame src="http://wodas.t7online.com/dynamic/wo_bf.fcgi?LANG=cn&KONT=cncn&LAND=CI&WMO=56294&ORTN=成都" noresize scrolling="no" name="werbung" marginwidth="0" marginheight="0">
<frame src="/cncn_akt.htm" noresize scrolling="no" marginwidth="0" marginheight="0">
<frameset cols="150,*" border="0" frameborder="0" framespacing="0">
<frame src="/include/cncn_region_vor.htm" scrolling="auto" name="linke_leiste" noresize marginwidth="0" marginheight="0">
<frame src="/cgi-bin/region?PRG=citybild&CONT=cncn&CREG=hkch&WMO=56294&LAND=CI&LANG=cn" scrolling="auto" name="WOcontent" noresize marginwidth="0" marginheight="0">
</frameset>
</frameset>
<frame src="http://wodas.t7online.com/dynamic/wo_sky.fcgi?LANG=cn&KONT=cncn&LAND=CI&WMO=56294&ORTN=成都" name="cntrechts" noresize scrolling="no" marginwidth="0" marginheight="0">
</frameset>
</html>
jiajiajing6 2012-07-25
  • 打赏
  • 举报
回复
frame src

源代码里是不是有好几个 上边这两个词啊... 这就是了.,
把src= 后边的网面地址 用idhttp去Get得到的就是你想要的东西啦... 
miceyou 2012-07-24
  • 打赏
  • 举报
回复
请高手指点。
miceyou 2012-07-24
  • 打赏
  • 举报
回复
我通过程序读取网页内容 只有几行 而我右键点‘7天’按钮旁空白处 显示源代码 出来代码很多 我就不知道该如何能读到那个代码

lin:='http://www.t7online.com/China/Chengdu.htm';
with IdHTTP1.Request do
begin
ContentType :='application/x-www-form-urlencoded';
UserAgent :='Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
end;

try
MyStr1:=IdHttp1.Get(lin);

except
Showmessage('网络出错!');
Exit;
end;
showmessage(mystr1);
kaikai_kk 2012-07-23
  • 打赏
  • 举报
回复
那要分析html源码,找出这个"7天"的链接地址,再用http读取

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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