茭白筍和百香果都是南投埔里鎮很重要的產物,高居全國榜首,佔88.2%,程式:
1
2
3
4
5
6
7
8
9
10
11
12
13 | import requests
from bs4 import BeautifulSoup
import pandas as pd
my_data = {'accountingyear': '109', 'item': '03', 'crop':'418',
'city':'0008', 'desc_asc':'desc'}
r = requests.post("https://agr.afa.gov.tw/afa/pgcropmeaqty_all.jsp",my_data )
soup = BeautifulSoup(r.text, 'lxml')
result = soup.find("div", class_="DivRestTbl")
dfs = pd.read_html(str(result))
df = dfs[0]
for item in range(1, 11):
print("茭白筍種植面積排第{}名的鄉鎮是{}, 佔合全國收量的{}%".format(
item, df.at[item+2,0], int(df.at[item+2,4])/int(df.at[2,4])*100))
|
沒有留言:
張貼留言