jeudi 14 septembre 2017

Web Scraping with Python .children and .descendants

When I use .children and .descendants, it will give me same print, why?

from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://ift.tt/2pr0Ni4")
bsObj = BeautifulSoup(html, "lxml")
for child in bsObj.find("table", {"id": "giftList"}).children:
    print(child)
for child in bsObj.find("table", {"id": "giftList"}).descendants:
    print(child)




Aucun commentaire:

Enregistrer un commentaire