# -*- coding:utf-8 -*- from selenium import webdriver # 导入webdriver包 # 导入friefox webdriver 包 from selenium.webdriver.firefox.firefox_binary import FirefoxBinary import time # 调入time函数 binary = FirefoxBinary( "C:\Program Files (x86)\Mozilla Firefox\firefox.exe") # 加入Firefox的路径 # 定义driver 要操控火狐浏览器 webdriver.firefox driver = webdriver.Firefox(firefox_binary=binary) driver.get("http://www.santostang.com/2018/07/04/hello-world/") driver.switch_to.frame(driver.find_element_by_css_selector("iframe[title='livere']")) comment = driver.find_element_by_css_selector('div.reply-content') content = comment.find_element_by_tag_name('p') print(content.text)
参考了这篇文章
https://www.cnblogs.com/ppppying/p/6143803.html