Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from bs4 import BeautifulSoup
- for index in range(1,28):
- vhi_url = requests.get('https://www.star.nesdis.noaa.gov/smcd/emb/vci/VH/get_provinceData.php?country=USA&provinceID={}&year1=1981&year2=2017&type=Mean'.format(index))
- soup = BeautifulSoup(vhi_url.text)
- head = soup.body.tt.pre.getText().split('\n')[0].replace('year,week,, provinceID, SMN,SMT,VCI,TCI,VHI', 'year,week,SMN,SMT,VCI,TCI,VHI')
- text = head + soup.body.tt.pre.getText().replace('year,week,, provinceID, SMN,SMT,VCI,TCI,VHI', '').replace(',', ' ').replace(' ', ' ').replace(' ',',')
- output = open('provience-{}.csv'.format(index), 'w')
- output.write(text)
- output.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement