随笔分类 - 爬虫 / Selenium
摘要:有些网站时一直滚动就会加载新数据的,在selenium中解决方法: ```Python def loaddata_by_scroll(self, driver): js = 'return document.body.scrollHeight;' # 获取当前高度 check_height = dr
阅读全文
摘要:```Python """ P.S:需要接管现有浏览器 ** 使用步骤: 1、打开浏览器,设置好远程调试端口,并扫描登录淘宝。 chrome.exe --remote-debugging-port=9333 --user-data-dir="G:\spider_taobao"** 2、运行程序,自动
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/waits/](https://www.selenium.dev/documentation/webdriver/waits/) 有时候我们需要等待网页上的元素出现后才能操作。selenium中可以使
阅读全文
摘要:无头模式适合的场景: - 部署到没有gui界面的服务器,比如linux - 开发环境测试完全没问题后可以使用无头模式,提高selenium速度。 ```YAML # 使用headless无界面浏览器模式 chrome_options.add_argument('--headless') chrome
阅读全文
摘要:```Python import random import time from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.chrome.service
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/actions_api/](https://www.selenium.dev/documentation/webdriver/actions_api/) 注意:对于滚轮的操作,只支持chrome浏览器
阅读全文
摘要:[https://www.selenium.dev/documentation/webdriver/elements/file_upload/](https://www.selenium.dev/documentation/webdriver/elements/file_upload/) 用的方法就
阅读全文
摘要:# 查找元素 官方文档:[https://www.selenium.dev/documentation/webdriver/elements/locators/](https://www.selenium.dev/documentation/webdriver/elements/locators/)
阅读全文
摘要:# 浏览器属性 > 在使用selenium过程中,实例化driver对象后,driver对象有一些常用的属性和方法 1. `driver.page_source` 当前标签页浏览器渲染之后的网页源代码。 2. `driver.current_url` 当前标签页的url。 3. `dirver.ti
阅读全文
摘要:```Python import time from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService # 驱动文件所在路径 DIRVER_PATH = r
阅读全文