用html语言制作个网站天气预报复杂不?要怎么做?

用html语言制作个网站天气预报复杂不?要怎么做?,第1张

网页本身不复杂,问题是天气预报的数据你怎么弄,如果你自己有那到没什么,做个简单的显示就行了。如果你没有数据,那就做个数据抓取程序上别人网站抓去吧,把抓过来的数据处理一下显示就行了。

每个语言都有抓取的函数,网上有代码你可以找一下,不过有点麻烦,还是使用楼下的那种别的网站提供的代码吧。

例如河南郑州的代码:你只需要在你网站插入下面语句就行了:<iframe src="http://m.weather.com.cn/m/pn1/weather.htm " width="235" height="20" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>

你可以在http://service.weather.com.cn/plugin/forcast.shtml?id=pn1选择你要显示城市的代码

<iframe src=" http://m.weather.com.cn/n/pn14/weather.htm" width="260" height="30" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>天气代码 //日期代码<script language="JavaScript">

function number(index1){

var numberstring="一二三四五六七八九十"

if(index1 ==0) {document.write("十")}

if(index1 <10){

document.write(numberstring.substring(0+(index1-1),index1))}

else if(index1 <20 ){

document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}

else if(index1 <30 ){

document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}

else{

document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}

}var today1 = new Date()

var month = today1.getMonth()+1

var date = today1.getDate()

var day = today1.getDay()

number(month)

document.write("月")

number(date)

document.write("日")

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6209319.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-18
下一篇 2023-03-18

发表评论

登录后才能评论

评论列表(0条)

保存