【发布时间】:2013-03-07 13:54:19
【问题描述】:
我正在制作一个 python 脚本来卷曲幻想曲棍球记分牌页面,调用 perl 以正则表达式替换球队名称和分数,并显示它。正则表达式已全部设置,但现在我无法获取网页。我注意到当我在运行
后在我的计算机上执行此操作时curl -o /tmp/fantasyhockey.txt http://games.espn.go.com/fhl/scor...
command,按回车键一次会启动它,然后再次按它会退出并创建我的页面。如何强制 python 按回车键?出于好奇,它为什么要等待?
编辑:这是脚本。没什么大不了的。
import os
def main():
os.system("curl -o /tmp/fantasyhockey.txt http://games.espn.go.com/fhl/scoreboar\
d?leagueId=xxxxx&seasonId=2013")
unfix = open("/tmp/fantasyhockey.txt", "r").read().replace('\n', '')
outfile = open("/tmp/fantasyhockey2.txt", "w")
outfile.write(unfix)
outfile.close()
os.system("perl regex.pl < /tmp/fantasyhockey2.txt")
os.system("rm /tmp/fantasyhockey*")
main()
【问题讨论】:
-
你能介绍一下执行 curl 的脚本吗?
-
包括在内。也可能有更好的方法来使用 curl 而不是强迫 python 做一些奇怪的事情。