简体   繁体   English

从 python 中的 ajax 网站中提取实时数据

[英]Extract real time data from ajax website in python

I would like to extract real time data from a webpage: http://www.fxstreet.com/rates-charts/forex-rates/我想从网页中提取实时数据: http://www.fxstreet.com/rates-charts/forex-rates/

I am programming in Python and I did an urlopen to take the htmlcode.我在 Python 编程,我做了一个 urlopen 来获取 htmlcode。 Then I used regular expressions to extract the numbers.然后我使用正则表达式来提取数字。 Problem is that I have to do an urlopen each second to get the latest data, its long not reliable and not clean... Can someone help without having to refresh the webpage ?问题是我必须每秒执行一次 urlopen 才能获取最新数据,它长期以来不可靠且不干净......有人可以提供帮助而无需刷新网页吗? thanks!谢谢!

Here's something to get you going.这里有一些东西可以帮助你。 Try the following from the command line:从命令行尝试以下操作:

curl -d '[{"channel":"/meta/connect","connectionType":"xhr-streaming","id":"15","clientId":"14799ac3-a0ac-43ab-8bb6-baad56886e11"}]' "http://ttpush.fxstreet.com/http_push/connect"

As you can see, as long as you keep the connection open, the site keeps pushing more data to you.如您所见,只要您保持连接打开,该站点就会不断向您推送更多数据。 I would think that would be easy to convert to Python.我认为这很容易转换为 Python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM