我正在尝试浏览网址列表并截取屏幕截图。这是代码片段。
def onLoadFinished(result):
#fo.write( column1[feed])#, column2[feed], urls[feed])
global feed
print urls
if not result:
print "Request failed"
#print urls[feed]
fo.write(str(column1[feed])+','+str(column2[feed])+','+str(urls)+','+'414'+','+'image not created\n')
feed = feed + 1
sys.exit(1)
save_page(webpage, outputs.pop(0)) # pop output name from list and save
if urls:
url = urls.pop(0) # pop next url to fetch from list
webpage.mainFrame().load(QUrl(url))
#print urls[feed]
fo.write(str(column1[feed])+','+str(column2[feed])+','+str(urls)+','+'200'+','+'image created\n')
feed = feed + 1
else:
app.quit() # exit after last url
webpage.connect(webpage, SIGNAL("loadFinished(bool)"), onLoadFinished)
webpage.mainFrame().load(QUrl(urls.pop(0)))
#fo.close()
sys.exit(app.exec_())
现在在 pages.mainFrame().load(QUrl(urls.pop(0))) 中,我希望它会继续弹出我的下一个 url ,但是一旦它进入 onloadfinished 方法,它就会第一次给我第二个 url 并且然后列表变为空,我得到错误弹出索引超出范围。
url 列表是 [1.2] .. 它第一次给我 2,第二次超出范围。任何想法如何从 1 到 2 依次获取它?