无法打开硒中的链接,因为它不是以https://或http://开头

时间:2018-06-21 06:24:50

标签: python selenium selenium-webdriver

这是我用python编写的用于打开youtube下载页面的代码

#! python3 
#web browser
import webbrowser,sys,pyperclip
from selenium import webdriver
browser=webdriver.Firefox()
sys.argv
if len(sys.argv)>1:
    address=' '.join(sys.argv[1:])
else:
    address=pyperclip.paste()
#https://www.youtube.com/watch?v=PHULePbksEU&lc=z23zexnimznmtjzhm04t1aokgivrnxqnqfdkgrw0qagprk0h00410
address=address[12:]    
#webbrowser.open("https://www.flipkart.com/search?q="+address)
browser.get("ss"+address)

我收到如下错误:-

Traceback (most recent call last):
  File "C:/Users/Ali Akber/AppData/Local/Programs/Python/Python36/youtubeDownloader.py", line 14, in <module>
    browser.get("ss"+address)
  File "C:\Users\Ali Akber\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 326, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\Ali Akber\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Ali Akber\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: Malformed URL: ss

网络浏览器

import webbrowser,sys,pyperclip

from selenium import webdriver

browser=webdriver.Firefox()

sys.argv

if len(sys.argv)>1:

    address=' '.join(sys.argv[1:])

else:

    address=pyperclip.paste()

https://www.youtube.com/watch?v=PHULePbksEU&lc=z23zexnimznmtjzhm04t1aokgivrnxqnqfdkgrw0qagprk0h00410

address = address [12:]

webbrowser.open(“ https://www.flipkart.com/search?q=” +地址)

browser.get(“ ss” +地址)

不是有效的网址。

0 个答案:

没有答案