Haré un pronóstico del tiempo en los últimos dos días. Recuerdo que cuando usaba la versión .net, solía tomar el tiempo de Baidu, escribirlo en texto y luego leerlo. Con el tiempo, aparecen muchos archivos de texto. No se siente muy bien. Busqué en Baidu y encontré los métodos de otras personas para mejorarlo.
Obtenga el sitio web del tiempo: http://www.weather.com.cn/html/weather/101210701.shtml Esto es Wenzhou. Por supuesto, busque otras ciudades y cambie la identificación.
Dado que las cookies se escriben para registrar el clima del día, es necesario navegar por el sitio.
código js:
Copie el código de código de la siguiente manera:
var URL=escape(http://m.weather.com.cn/data/101210701.html);
var información_COOKIE = información_COOKIE;
var fecha = nueva fecha();
var Horas=24-date.getHours()-1;
var Mins=60-date.getMinutes()-1;
varSecs=60-fecha.getSeconds();
date.setTime(date.getTime() + (1 * Horas * 60 * 60 * 1000) + (1 * 1 * Minutos * 60 * 1000) + (1 * 1 * 1 * Segundos * 1000));
var RD_cookie_info= $.cookie(COOKIE_info);
$(función(){
si(RD_cookie_info==nulo)
{
Obtener datos (URL);
}
demás{
$(#clima).html(RD_cookie_info);
}
})
función Obtener datos (URL)
{
$.ajax({
tipo: OBTENER,
caché: falso,
URL: AjaxGet.asp,
datos: URL = + URL,
tipo de datos: html,
error: function(){$(#weather).html(Error de lectura... ¡Actualice e inténtelo de nuevo!);},
éxito: función (json) {
var t = '('+json+')';
resultado var = eval(t);
var Obtenerinfo=;
Getinfo+=result.weatherinfo.date_y+ ;//Año, mes y día
Getinfo+=result.weatherinfo.date+ ;//Año, mes y día del calendario lunar
Getinfo+=result.weatherinfo.week+ ;//Día de la semana
Getinfo+=<br />;//Salto de línea
Getinfo+=result.weatherinfo.city;//Obtener el nombre de la ciudad
Getinfo+= <img src=/http://m.weather.com.cn/img/c+result.weatherinfo.img1+.gif//> //Imagen del tiempo 1
Getinfo+=<img src=/http://m.weather.com.cn/img/c+result.weatherinfo.img2+.gif//> ;//Imagen del tiempo 2
Getinfo+=result.weatherinfo.weather1+ ;//Condiciones climáticas
Getinfo+=result.weatherinfo.temp1;//Temperatura
$.cookie(COOKIE_info,Getinfo, {ruta: '/', caduca: fecha });
$(#clima).html(Obtenerinfo);
}
});
}
código html:
Copie el código de código de la siguiente manera:
<div id=estilo meteorológico=tamaño de fuente:12px;></div>
Esto utiliza el rastreo asp común en Internet. Por supuesto, también se puede reemplazar con el rastreo .net u otro.