将列表中的URL解析为子进程调用

时间:2013-12-17 19:08:55

标签: parsing python-2.7 subprocess phantomjs yslow

问题是调用以识别call命令中的o.geturl()命令。

from subprocess import call
import time
from urlparse import urlparse

def ListOfTests():
    myFile = open("testUrlToImport.txt", "r")
    myLines = list(myFile)
    myFile.close()

    for urls in myLines:
        urlsAsAString = str(urls)
        o =urlparse(urlsAsAString)

        call(["phantomjs", "yslow.js", "--info", "basic", "--format", "plain", "o.geturl()"])

任何指针都表示赞赏。谢谢!

1 个答案:

答案 0 :(得分:2)

您应该从o.geturl()中移除引号。这应该有效:

call(["phantomjs", "yslow.js", "--info", "basic", "--format", "plain", o.geturl()])