How to dispaly data from html tags using python Beautiful Soup
import requests
from bs4 import BeautifulSoup
link = "http://www.flipkart.com/mobiles?otracker=hp_header_nmenu_sub_Electronics_0_Mobiles"
doc = requests.get(link)
soup = BeautifulSoup(doc.text, 'html.parser')
main_div = soup.find(id="list-tagcloud")
div2=main_div.find_all('div')[1]
for x in div2.strings:
print x
OUTPUT
======
Motorola
Lenovo
Samsung
LeEco
Yunicorn
Honor
Mi
Asus
Apple
Intex
Sony
Alcatel
Lava
Gionee
All
from bs4 import BeautifulSoup
link = "http://www.flipkart.com/mobiles?otracker=hp_header_nmenu_sub_Electronics_0_Mobiles"
doc = requests.get(link)
soup = BeautifulSoup(doc.text, 'html.parser')
main_div = soup.find(id="list-tagcloud")
div2=main_div.find_all('div')[1]
for x in div2.strings:
print x
OUTPUT
======
Motorola
Lenovo
Samsung
LeEco
Yunicorn
Honor
Mi
Asus
Apple
Intex
Sony
Alcatel
Lava
Gionee
All
Comments
Post a Comment