小编Luc*_*zen的帖子

使用BeautifulSoup获取“查看元素”代码而不是“查看源代码”

我正在使用以下代码<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搜索。

我希望它这样做是因为我真正感兴趣的代码是元素代码,而不是源代码。

html javascript python beautifulsoup

1
推荐指数
1
解决办法
1475
查看次数

标签 统计

beautifulsoup ×1

html ×1

javascript ×1

python ×1