使用selenium时需要确保电脑上已经下载了浏览器对应版本的webdriver
先附初始代码

#导入库
from selenium import webdriver
#声明浏览器对象并调用
browser = webdriver.Chrome
url = ‘https://www.baidu.com/’
browser.get(“https://www.baidu.com/”)
#打印网页源代码
print(browser.page_source)
browser.close()#关闭浏览器
这时会报一个错误:
TypeError: get() missing 1 required positional argument: ‘url’

错误一解决办法

经调查发现需要将
browser = webdriver.Chrome
改为browser = webdriver.Chrome()
此时又会报错

错误二解决办法

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH.
原因是没有配置chromedriver.exe的环境变量
下载对应谷歌浏览器对应版本的chromedriver.exe,将其复制到chrome的安装位置,接下来配置chromedriver.exe的环境变量。修改Path,编辑上chromedriver.exe的位置
C:\Program Files (x86)\Google\Chrome\Application
仍然报错
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH.

错误三解决办法

放弃上述办法,把chromedriver放到一个自己喜欢的位置
我放在了D:\chromedriver文件夹下。

#调用浏览器
# 导入库
from selenium import webdriver
#声明浏览器对象并调用
chrome_driver=r"D:\chromedriver\chromedriver.exe"
browser = webdriver.Chrome(executable_path=chrome_driver)#调用浏览器
url = 'https://www.baidu.com/'
#打开浏览器预设网址
browser.get("https://www.baidu.com/")
#打印网页源代码
print(browser.page_source)
browser.close()#关闭浏览器


执行成功!!!!!
感谢大佬博客https://blog.csdn.net/weixin_43746433/article/details/95237254

解决TypeError: get() missing 1 required positional argument: 'url'相关推荐

  1. 成功解决TypeError: drop() missing 1 required positional argument: 'labels'

    成功解决TypeError: drop() missing 1 required positional argument: 'labels' 目录 解决问题 解决思路 解决方法 解决问题 TypeEr ...

  2. 解决 TypeError: xxx() missing 1 required positional argument: 'astr'

    错误代码 TypeError: xxx() missing 1 required positional argument: 'astr' 错误原因 没有对类进行实例化如下. Solution.isUn ...

  3. TypeError:__init__() missing 1 required positional argument :‘problem‘

    成功解决TypeError:__init__() missing 1 required positional argument :'problem' 偶然遇见python报错__init__() mi ...

  4. 解决Django: [TypeError: __init__() missing 1 required positional argument: 'on_delete']

    试用python3.7 + Django2.1.3的时候, 在创建模型类关联外键时, 报如下错误: Traceback (most recent call last):xxxxxxxxxxx Type ...

  5. 【bug解决】TypeError: forward() missing 1 required positional argument: ‘x‘

    项目场景: 进行ReLU类的实例运算时,出现了问题 问题描述 import numpy as npclass ReLU():def __init__(self):self.mask = Nonedef ...

  6. TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决办法

    Django 中创建Model时报以下错误: TypeError: init() missing 1 required positional argument: 'on_delete' 代码如下: f ...

  7. 关于错误TypeError: get_biff_record() missing 1 required positional argument: ‘self‘的解决

    在进行python实现Excel自动化的过程中出现了TypeError: get_biff_record() missing 1 required positional argument: 'self ...

  8. Django - TypeError: __init__() missing 1 required positional argument: ‘on_delete‘ 的解决办法

    Django 中创建Model时报以下错误: TypeError: init() missing 1 required positional argument: 'on_delete' 代码如下: f ...

  9. 【Python】django报错:TypeError: __init__() missing 1 required positional argument: 'on_delete'解决办法

    错误代码: from __future__ import unicode_literals from django.db import models from django.utils.encodin ...

最新文章

  1. 网页中加载obj模型比较慢_Web前端优化技巧分享,让你的网页显示的更流畅
  2. 编码导致 html和aspx 样式差异,变形
  3. java怎么把system.out的东西输出到文件上
  4. python批量下载文件教程_Python抓包菜鸟教程:批量下载图片的方法,电脑和手机都能用...
  5. DELPHI怎样编写COM组件
  6. Flex 中 12 个简单实用的小技巧
  7. 2016值得关注的5大IT趋势
  8. 对接第三方支付接口-记录
  9. android 学习 解决R.java不能自动生成问题,编译时adb.exe 找不到问题
  10. react router 4
  11. python tkinter界面 控件位置随窗体自动调整适应_如何实现python tkinter控件随窗口变化?...
  12. 如何设置蓝牙音频设备与Mac配合使用呢?
  13. https的安装(基于阿里云)
  14. 从3dmax导出动画总结
  15. Python模块大全(Mark随用随看)
  16. mongodb安装及操作
  17. E. Xenon's Attack on the Gangs,Codeforces Round #614 (Div. 2),树形dp
  18. Vue微信网页开发,输入法顶开一部分屏幕的解决办法
  19. 有计算机考试励志的文案,中考励志文案(精选50句)
  20. 图像平移 ——MATLAB实现

热门文章

  1. 和为S的两个数字,编程题解法思路
  2. select * 和select 所有字段的区别
  3. PLSQL Developer 12安装
  4. 2015.05.11,外语,读书笔记-《Word Power Made Easy》 15 “如何谈论事情进展” SESSION 43...
  5. 哪些域名后缀可以备案?
  6. 碳化硅SiC MOSFET:低导通电阻和高可靠性的肖特基势垒二极管
  7. 肖特基二极管厂家和快恢复二极管厂家ASEMI有哪些型号
  8. 根据年龄, 来打印出当前年龄的人是少年(低于18), 青年(19-28), 中年(29-55), 老年(56以上)
  9. 我心中的vi 编辑神器
  10. 用OpenCV实现Photoshop算法(八): 可选颜色