网上看到很多日历,万年历数据基本开源。但是老黄历可是难找。很多要花钱才能下载,
或者有免费接口,还得注册。干脆自己爬取数据,将来好用得着。直接上代码。
import requests
import json
import time
import pandas as pd
import re
from bs4 import BeautifulSoup
from collections import OrderedDict
import csv
import random
year=range(1900,2099)
month=range(1,13)
def geturl():
for i in year:
for j in month:
for k in range(1,32):
if j<10 and k<10:
day=str(i)+'0'+str(j)+'0'+str(k)
url= "http://nongli.dunkun.com/"+ str(day)+".html"
elif j<10 and k>=10:
day=str(i)+'0'+str(j)+str(k)
url