我想在我的linux机器上找到没有文件扩展名约束的人类可读文件.这些文件应该是人类感知文件,如文本,配置,HTML,源代码等文件.你能建议一种过滤和定位的方法吗?
我编写了一个小脚本来获取即时股票价格。
#script to get stock data
from __future__ import print_function
import urllib
import lxml.html
from datetime import datetime
import sys
import time
stocks=["stock1","stock2","stock3","stock4","stock5"]
while True:
f=open('./out.txt', 'a+')
for x in stock:
url = "http://someurltofetchdata/"+x
code = urllib.urlopen(url).read()
html = lxml.html.fromstring(code)
result = html.xpath('//td[@class="LastValue"][position() = 1]')
result = [el.text_content() for el in result]
f.write(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' ' + x + ' ' + result[0])
f.write("\n")
f.close()
Run Code Online (Sandbox Code Playgroud)
我希望该代码仅在股市开放时间(即交易时间)获取数据。(09:00 至 12:30 和 13:30 至 17:30)。
您能否建议一种在代码上隐式执行调度的方法?(不在操作系统级别)