python清除历史记录_python 历史数据删除法则

#!/usr/bin/env python

#-*- coding:UTF-8 -*-

"""

@Item   :  database Backup

@Author :  Villiam Sheng

@Date   :  2012-08-13

@Funtion:

"""

import os,sys,time,re,socket,threading,json,base64,traceback,ConfigParser,fcntl,struct

from rsync_log import rsync_log

from rsync_post import rsync_post

from  statvfs import F_BLOCKS,F_BAVAIL,F_BSIZE

pcg = 0

""" 生成斐波那契数列"""

lists = []

a,b = 0,1

while b <= 365:

a,b = b ,a+b

lists.append(b)

class rsync_thread(threading.Thread):

def __init__(self,path):

threading.Thread.__init__(self)

self.log = rsync_log()

self.path = path

""" 计算当前磁盘的使用百分比"""

def disk(self):

try:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,您想了解如何用 Python 爬取历史天气数据,是吗? 首先,需要确定您想要爬取哪个地区的历史天气数据。一般来说,可以通过查询该地区的气象局或气象网站获取历史天气数据。 接着,可以使用 Python 中的 requests 库来发送 HTTP 请求,获取网页源代码。然后,可以使用 BeautifulSoup 库来解析网页源代码,提取出所需的天气数据。 以下是一个简单的示例代码,用于爬取中国天气网上北京市 2019 年 1 月份的历史天气数据: ``` python import requests from bs4 import BeautifulSoup url = 'http://www.weather.com.cn/weather/101010100.shtml#dt' headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'} r = requests.get(url, headers=headers) r.encoding = 'utf-8' soup = BeautifulSoup(r.text, 'html.parser') weather_list = soup.select('.t li') for weather in weather_list: date = weather.select('.time')[0].text weather_detail = weather.select('.temp')[0].text.strip() print(date, weather_detail) ``` 以上代码中,我们首先通过 requests 库发送了一个 GET 请求,获取了北京市天气网的网页源代码。然后,使用 BeautifulSoup 库解析网页源代码,提取出了 2019 年 1 月份的天气数据,并打印输出了日期和天气详情。 需要注意的是,不同的网站网页结构不同,需要根据具体情况修改代码。同时,需要注意网站的 robots.txt 文件,不要过度访问网站,以免被封 IP 或其他限制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值