美しいスープを使用できます。特定のhtmlタグ間であなたの望むデータを取得する。自分でやりたいのであれば、サイトのapiを呼び出してデータを投稿することができます。最初のインストール要求。 pip install requests
その後、
import re
import requests
# the data is between align="left"><font size="3px"> and </font> in each specific part so we use re to find it
def find_data(line):
return re.search('align="left"><font size="3px">(.*?)</font>', line).group(1)
params = {
'tags': city_name,
'submit': 'Go'
}
response = requests.post('http://www.indiaweather.gov.in/?page_id=942', data=params).content.splitlines()
try:
current_temp = find_data(response[357])
max_temp = find_data(response[362])
min_temp = find_data(response[369])
last_day_rainfall = find_data(response[376])
current_wind_direction = find_data(response[382])
current_wind_speed = find_data(response[389])
current_dew_point = find_data(response[396])
current_sea_level_pressure = find_data(response[403])
print(current_temp, max_temp, min_temp, last_day_rainfall, current_wind_direction, current_wind_speed,
current_dew_point, current_sea_level_pressure)
except IndexError:
print('No Info Found For %s' % params['tags'])
ギッターに私を見つけるこの私のnickanmeを行う方法を教えてくれます:dexax –
@Vin、あなたは見当がつかない場合、あなたは多分あなたのためにそれを行うには、開発者を雇う必要があります。 –