[問題] 爬蟲找不到frame

看板Python作者 (姑叔城外含三次)時間8年前 (2017/12/04 02:54), 編輯推噓1(100)
留言1則, 1人參與, 8年前最新討論串1/1
小弟剛剛發了兩篇文但後來發現好像沒有提到重點 所以再重發一次 因為小弟要爬的lawsnote是js生成的所以想說就直接用selenium去解 但是發現selenium定位不到元素所以想說是不是frame在搞鬼 以下我的程式碼 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains from bs4 import BeautifulSoup as bs import time driver = webdriver.Chrome(executable_path=r'/Users/terry/chromedriver') driver.get("https://www.lawsnote.com/") driver.find_element_by_xpath("//input[@value='']").click() driver.find_element_by_xpath("//input[@value='']").send_keys(u"醫療") driver.find_element_by_xpath("//div[@id='root']/div/div/div/div[3]/div/button").click() soup=bs(driver.page_source,'html.parser') print(soup) 我想找的是id為1 2 3 ...的連結也就是搜尋結果的那些連結,想知道他們到底被藏在哪裡 小弟算爬蟲界的幼幼班拜託各位大大了 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.149.1 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1512327267.A.B8E.html

12/04 13:45, 8年前 , 1F
https://tinyurl.com/yb3sppdu 等element出來再抓就好
12/04 13:45, 1F
文章代碼(AID): #1Q94XZkE (Python)