Python 如何从网站上获取信息到图表上?

Python 如何从网站上获取信息到图表上?,python,numpy,matplotlib,web,graph,Python,Numpy,Matplotlib,Web,Graph,我正试图从一个冲浪网站上获取信息,并将其放在我找到的图表上。如何更改代码以显示信息 from bs4 import BeautifulSoup` import requests import numpy as np import matplotlib.pyplot as plt page_link = 'http://widgets.windalert.com/widgets/web/forecastTable?spot_id=110&units_wind=mph&units_

我正试图从一个冲浪网站上获取信息,并将其放在我找到的图表上。如何更改代码以显示信息

from bs4 import BeautifulSoup`
import requests
import numpy as np
import matplotlib.pyplot as plt

page_link = 'http://widgets.windalert.com/widgets/web/forecastTable?spot_id=110&units_wind=mph&units_height=ft&units_temp=F&days=4'
page_response = requests.get(page_link, timeout=5)
page_content = BeautifulSoup(page_response.content, "html.parser")
paragraphs = page_content.find_all("p")[i].text

res = requests.get('https://scotch.io')
print(res)

r = requests.get("http://widgets.windalert.com/widgets/web/forecastTable?spot_id=110&units_wind=mph&units_height=ft&units_temp=F&days=4")
print (r.json)
print(r.text)


x1 = np.linspace(0.0, 12.0)
x2 = np.linspace(0.0, 12.0)

y1 = np.cos(2 * np.pi * x2) 
y2 = np.cos(2 * np.pi * x2)

plt.subplot(2, 1, 1)
plt.plot(x1, y1, 'o-')
plt.title('Wave size in Boca Raton')
plt.ylabel('Height(ft)')

plt.subplot(2, 1, 2)
plt.plot(x2, y2, '.-')
plt.xlabel('Time')
plt.ylabel('Tide')

plt.show()

如果您在Chrome/Firefox的选项卡
Network
中签入
DevTools
,您将看到它从url
https://api.weatherflow.com/...

import requests

url = 'https://api.weatherflow.com/wxengine/rest/model/getModelDataBySpot?model_id=-1&spot_id=110&units_wind=mph&units_temp=F&format=json&wf_apikey=84e778ae-fe8e-4b8f-8d33-6bc88967a2b1&wf_token=f147702351af100d7c220b633d085318&v=1.1'
r = requests.get(url)
data = r.json()

for row in data['model_data']:
    print(row['model_time_local'], '|', row['wind_speed'], '|', row['temp'])
部分结果:

2020-02-10 13:00:00-0500 | 14.8 | 78.3
2020-02-10 14:00:00-0500 | 14.4 | 77.9
2020-02-10 15:00:00-0500 | 14.0 | 77.4
2020-02-10 16:00:00-0500 | 13.8 | 77.0
2020-02-10 17:00:00-0500 | 14.2 | 76.4
2020-02-10 18:00:00-0500 | 14.6 | 75.8
2020-02-10 19:00:00-0500 | 15.0 | 75.2
2020-02-10 20:00:00-0500 | 14.9 | 75.3
2020-02-10 21:00:00-0500 | 14.9 | 75.3
2020-02-10 22:00:00-0500 | 15.1 | 75.4

什么信息?如何显示?Scott Hunter如果你看我的代码,有一个网站链接可以将你带到冲浪预测,还有一个由我的代码生成的图形,我正在尝试将该网站的信息插入其中。