2013-10-24 37 views

回答

0

你需要使用 「」」(3個引號),你似乎只有兩個用

例:

""" 
This block 
is commented out 
""" 

快樂編碼

編輯:這是不是用戶問了什麼,我的道歉。

我沒有經驗美麗的湯,但我發現了一個代碼片上SO可能適合你(source):

soup = BeautifulSoup(source.lower()) 
to_extract = soup.findAll('ahref') #Edit the stuff inside '' to change which tag you want items to be removed from, like 'ahref' or 'head' 
for item in to_extract: 
    item.extract() 

通過它的外觀,它可能只是刪除您的網頁上的每一個環節,雖然。

對不起,如果這不能幫助你更多!

+0

沒有。我的意思是完全用「」替換頭部。「 – user2878953

+0

哦!哦,我現在明白了。我正在修改我的答案,我的歉意。 – jwarner112

1

試試這個:

[head.extract() for head in soup.findAll('head')]