2016-12-04 18 views
1

我與BeautifulSoup有問題。我試圖從本網站每個表中提取數據:http://www.fantagazzetta.com/voti-serie-a/2016-17/6BeautifulSoup無法正常工作

然而BeautifulSoup跳過很多代碼行,這是我的python腳本:

from bs4 import BeautifulSoup 
import requests 

url = requests.get('http://www.fantagazzetta.com/voti-serie-a/2016-17/4') 
soup = BeautifulSoup(url.text, 'lxml') 
data = soup.find_all('div',{'class':'row no-gutter tbvoti'}) 
print(data) 

我的輸出僅僅是這樣的:

<div class="row no-gutter tbvoti" data-team="1" id="Ata"></div> 

如何提取每個表格內的代碼? 謝謝,對不起,我的英語

enter image description here

我的意思是跳過前之間::代碼::後,我想將其解壓縮。

回答

1

你應該在列表上迭代find_all回報:

from bs4 import BeautifulSoup 
import requests 

url = requests.get('http://www.fantagazzetta.com/voti-serie-a/2016-17/4') 
soup = BeautifulSoup(url.text, 'lxml') 
data = soup.find_all('div',{'class':'row no-gutter tbvoti'}) 

print(' '.join([str(part) for part in data])) 
+0

感謝的答案,但問題不在於:),我已經上傳了圖片,清楚 – manfr27