大江131 2022-05-29 01:42 采纳率: 20%
浏览 108
已结题

python中driver.find_elements_by_xpath结果乱码

问题遇到的现象和发生背景
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get("https://www.znlzd.com/bqg/20997/")
# html=driver.page_source

a = driver.find_elements_by_xpath('/html/body/div[3]/div[2]/div/div[3]/span[2]/select//option')
for i in a:
    print(i)


driver.close()


问题相关代码,请勿粘贴截图
运行结果及报错内容
<selenium.webdriver.remote.webelement.WebElement (session="b709b4ffe71161ec4fa5f4b33573d689", element="039639af-36ce-449e-af3b-027f9b25ea16")>

我的解答思路和尝试过的方法
我想要达到的结果
<option value="/bqg/20997/index_2.html">第21章 - 40章</option>

img

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 6月6日
  • 已采纳回答 5月29日
  • 修改了问题 5月29日
  • 修改了问题 5月29日
  • 展开全部