首页 > 解决方案 > 用于在 python 中抓取 javascript 的 Selenium:使用 page_source

问题描述

尝试抓取网站的数据,但这些是由 javascript 编辑的。所以,退出使用 beautifulSoup 并改为 Selenium。但是,结果与我的代码相同。据我所知,使用 Selenium 可以抓取 javascripts html,但我找不到这些...

import requests
from bs4 import BeautifulSoup as bs
from selenium import webdriver

for url in Url_Number:
driver = webdriver.Chrome(C:\Python_Study\chromedriver.exe.')
driver.implicitly_wait(3)
Real_url = 'http://www.sbiz.or.kr/sijangtong/nation/onnuri/pop/onnuriShopListPopup.do?cpage=1&mkt_cd=100101&mkt_gubun=O&shop_table=SJTT.MKT_ELE_SHOP'
driver.get(Real_url)
html=driver.page_source 
print(html)

print(html) 的结果,无法找出用 javascript 编写的表格数据...

如何使用 selenium 处理 javascript 数据?

标签: javascriptpythonselenium

解决方案


推荐阅读