如何使用Python固定交互式网页
我想知道以下网站: http://chonos.ifop.cl/flow/
网页在右侧有一个地图,当您单击HighCharts图中左时间序列上显示的每个点时,我想迭代地提取这些系列,但我仍然不能。到目前为止,这是我的代码:
from io import BytesIO
import gzip
site_url='http://chonos.ifop.cl/flow/'
r = urllib.request.urlopen(site_url)
site_content = r.read()
s = BeautifulSoup(site_content, 'html.parser')
print(s.prettify()[:100])
s.find_all('td')
s.find_all('table')
s.findAll('table',attrs={'class':'uk-table uk-table-small uk-table-striped'})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我在firefox/chrome中使用
devtools
(tab:网络
)以查看所有浏览器在我单击地图时浏览器发送到服务器的请求,然后我在下面看到这样的url,一些JSON数据,有名称系列
。您可以单击此链接以直接在浏览器中查看JSON数据
我也可以在代码
结果中使用此链接:
在链接中,我看到
lat =
,lon =
- 因此,如果您会更改纬度您应该获取其他位置的数据。编辑:
如所说的@Modammed-当您单击特殊位置时,它会从链接中加载数据,例如
https://chonos.ifop.cl/flow/stnclick?index=50
,您可以以与以前的链接相同的方式使用此链接。
如果您更改
索引
,则获得不同的位置。结果(每个位置的前5个值):
When I use
DevTools
in Firefox/Chrome (tab:Network
) to see all requests which browser sends to server when I click on map then I see url like this belowe which gives some JSON data and there is nameseries
.You can click this link to see JSON data directly in browser
http://chonos.ifop.cl/flow/mapclick?&REQUEST=GetFeatureInfo&SERVICE=WMS&SRS=EPSG%3A4326&STYLES=&TRANSPARENT=true&VERSION=1.1.1&FORMAT=image%2Fpng&BBOX=-84.48486328125%2C-50.16282433381728%2C-59.54589843750001%2C-45.75219336063107&HEIGHT=300&WIDTH=1135&LAYERS=aguadulce%3Aoutlet_points&QUERY_LAYERS=aguadulce%3Aoutlet_points&INFO_FORMAT=text%2Fhtml&LAT=-46.528634695271684&LON=-71.41113281250001&X=595&Y=51
And I can use this link also in code
Result:
In link I see
LAT=
,LON=
- so if you will change latitude, longtitude` then you should get data for other locations.EDIT:
As said @Modammed - when you click on special locations then it loads data from links like
https://chonos.ifop.cl/flow/stnclick?index=50
and you can use this link in the same way as previous link.
If you change
index
then you get different location.Result (first 5 values for every location):