1
出於某種原因,我無法從這個簡單的html表中提取表。如何從簡單的html表中提取行?
from bs4 import BeautifulSoup
import requests
def main():
html_doc = requests.get(
'http://www.wolfson.cam.ac.uk/old-site/cgi/catering-menu?week=0;style=/0,vertical')
soup = BeautifulSoup(html_doc.text, 'html.parser')
table = soup.find('table')
print table
if __name__ == '__main__':
main()
我有這張表,但我無法很好地理解beautifulsoup文檔,知道如何提取數據。數據在tr
標籤。
該網站顯示一個簡單的HTML食品菜單。
我想輸出一週的這一天的白天和菜單:
Monday:
Lunch: some_lunch, Supper: some_food
Tuesday:
Lunch: some_lunch, Supper: some_supper
等一週中的每一天。 '正式大廳'可以忽略。
如何遍歷tr
標籤,以便我可以創建此輸出?
我剛剛檢查HTML源代碼,而我只能看到的' 很多的 '...是誰寫的? –