Skip to content

Commit 657c16d

Browse files
committed
sprider
1 parent 1a5729c commit 657c16d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

newcodes/answers/q74.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
import requests
5+
from bs4 import BeautifulSoup
6+
import time
7+
8+
def get_data(url):
9+
req = requests.get(url)
10+
11+
soup = BeautifulSoup(req.text, 'lxml')
12+
try:
13+
table = soup.select("#ContentPlaceHolder1_lbldata table table")[0].find_all("td")
14+
province = table[0].find("b").string
15+
province = str(province)
16+
crop_name = str(table[6].string)
17+
crop_number = str(table[7].string)
18+
return province, crop_name, crop_number
19+
except:
20+
return False
21+
22+
if __name__ == "__main__":
23+
for i in range(11, 66):
24+
url = "http://202.127.42.157/moazzys/nongqing_result.aspx?year=2015&prov={}%20%20%20&item=01&type=1&radio=1&order1=year_code&order2=prov_code&order3=item_code".format(i)
25+
result = get_data(url)
26+
if result:
27+
print(result)
28+
else:
29+
print("hahha")
30+
time.sleep(1)

0 commit comments

Comments
 (0)