Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用spyder(python)打开网站并按时间刷新_Python_Python 3.x_Loops - Fatal编程技术网

使用spyder(python)打开网站并按时间刷新

使用spyder(python)打开网站并按时间刷新,python,python-3.x,loops,Python,Python 3.x,Loops,我的代码在这里我想打开一个youtube链接,10秒后会刷新我的代码,但无法执行请帮助我: import os import time import webbrowser cycles=12 num=3 delay=0.10 chromedir = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' website = input("http:\youtu.be/RsWCo_xGXxY") hits=c

我的代码在这里我想打开一个youtube链接,10秒后会刷新我的代码,但无法执行请帮助我:

import os 
import time 
import webbrowser

cycles=12 
num=3 
delay=0.10 
chromedir = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' 
website = input("http:\youtu.be/RsWCo_xGXxY") 
hits=cycles*num
print("You will access " +website+ " " , hits, " times")

for i in range(cycles): 
    for i in range(0,num): 
        webbrowser.get(chromedir).open(website)
        time.sleep(delay) 
        os.system("tskill /A iexplore") 
        os.system("tskill /A Chrome")

可能是
selenium
。此处用于安装::


您的“代码”在我看来不像Python代码。请麻烦格式化它。这是一个在spyderNo中执行的python代码。python解释器将永远执行第一行。你必须格式化你的代码。发布这样的垃圾是完全不尊重的。我认为Selenium可以解决这个问题,或者使用Selenium webdriver,或者pyautogui来执行cmd-r/ctrl-r击键。得到错误:AttributeError:“module”对象没有属性“webdriver”,driver=Selenium.webdriver.Chrome(chromedir)再次显示错误:raceback(最近一次调用last):文件“C:/Python34/Pselenium/youtube.py”,第3行,在driver=wd.chromedir(chromedir)文件“C:\Python34\lib\site packages\selenium\webdriver\Chrome\webdriver.py”中,第68行,在init self.service.start()文件“C:\Python34\lib\site packages\selenium\webdriver\common\service.py”中,第104行,在启动时引发WebDriverException(“无法连接到服务%s”%self.path)selenium.common.exceptions.WebDriverException:消息:无法连接到服务C:/Program Files(x86)/Google/Chrome/Application/Chrome.exe
from selenium import webdriver as wd
chromedir = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'
driver = wd.Chrome(chromedir)
website = input("http:\youtu.be/RsWCo_xGXxY") 
driver.open(website)
def until_func(driver):
    driver.refresh()
orderElem = WebDriverWait(driver, timeout=60, poll_frequency=10).until(until_func)