我正在使用以下代码<script>...</script>从网页获取所有内容(请参见代码中的url):
import urllib2
from bs4 import BeautifulSoup
import re
import imp
url = "http://racing4everyone.eu/2015/10/25/formula-e-201516formula-e-201516-round01-china-race/"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page.read())
script = soup.find_all("script")
print script #just to check the output of script
Run Code Online (Sandbox Code Playgroud)
但是,BeautifulSoup会在网页的源代码(镶边中为Ctrl + U)内搜索。但是,我想在网页的元素代码(Chrome中为Ctrl + Shift + I)内进行BeautifulSoup搜索。
我希望它这样做是因为我真正感兴趣的代码是元素代码,而不是源代码。