Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.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
Python 在selenium webdriver中输入字符串时收到错误消息_Python_Selenium_Selenium Webdriver_Webdriver - Fatal编程技术网

Python 在selenium webdriver中输入字符串时收到错误消息

Python 在selenium webdriver中输入字符串时收到错误消息,python,selenium,selenium-webdriver,webdriver,Python,Selenium,Selenium Webdriver,Webdriver,我不知道为什么webdriver不接受我的字符串参数 from selenium import webdriver driver = webdriver.Firefox() name = "Andre Silva" headline = "Football Player and CEO" url = "https://www.linkedin.com/search/results/index/?keywords=" + name + " " + headline + "&origin=

我不知道为什么webdriver不接受我的字符串参数

from selenium import webdriver

driver = webdriver.Firefox()
name = "Andre Silva"
headline = "Football Player and CEO"
url = "https://www.linkedin.com/search/results/index/?keywords=" + name + " " + headline + "&origin=GLOBAL_SEARCH_HEADER"

driver.get(url)
然后我收到一条错误消息:

  File "/Users/jiajiefan/data_mining/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 268, in get
    self.execute(Command.GET, {'url': url})
  File "/Users/jiajiefan/data_mining/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "/Users/jiajiefan/data_mining/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: 'url' not a string

您的代码在Python 3.6.1上运行良好。关于python2.7不确定这可能是问题所在,也可能不是问题所在,但是URL中不应该有空格。尝试将关键字之间的空格替换为
%20
链接=”https://www.linkedin.com/search/results/index/?keywords=“+name+”“+headline+”&origin=GLOBAL\u SEARCH\u HEADER”
replaceit@DebanjanB,我正在使用python2.7。它一直在说“url”不是一个string@JohnGordon,linkedin.com有时不会占用%20或09%。您的代码在
Python 3.6.1
上运行良好。关于python2.7不确定这可能是问题所在,也可能不是问题所在,但是URL中不应该有空格。尝试将关键字之间的空格替换为
%20
链接=”https://www.linkedin.com/search/results/index/?keywords=“+name+”“+headline+”&origin=GLOBAL\u SEARCH\u HEADER”
replaceit@DebanjanB,我正在使用python2.7。它一直在说“url”不是一个string@JohnGordon,linkedin.com有时不接受%20或09%