<p><p>沒有JavaScript支援:
import requests from bs4 import BeautifulSoup response = requests.get(my_url) soup = BeautifulSoup(response.text) soup.find(id="intro-text") # Output: <p><p>有JavaScript 支援(Selenium):
from selenium import webdriver driver = webdriver.PhantomJS() driver.get(my_url) p_element = driver.find_element_by_id(id_='intro-text') print(p_element.text) # Output: Yay! Supports javascript<p>支援JavaScript (dryscrape):
以上是如何使用 Python 抓取 JavaScript 產生的動態 Web 內容?的詳細內容。更多資訊請關注PHP中文網其他相關文章!