python 2.7 - print only 5 links using loop of crawled link from website -


need print 10 brands name particular website mentioned in url please me

from re import findall import csv import re import urllib bs4 import beautifulsoup  def brand_name_link("https://priceraja.com/mobile/brands/"):         htmlfile= urllib.urlopen(url)     #htmltext = htmlfile.read()     data=[]     link=[]     soup = beautifulsoup(htmlfile, 'html.parser')     name_box = soup.find('ul', attrs={'class': 'top-brands'})         tag in name_box.find_all('img'):         tag.replacewith('')         link=tag     link=name_box.find_all('a')      print link 

def brand_name_link(url):        htmlfile= urllib.urlopen(url)     #htmltext = htmlfile.read()     data=[]     link=[]     soup = beautifulsoup(htmlfile, 'html.parser')     name_box = soup.find('ul', attrs={'class': 'top-brands'})         tag in name_box.find_all('img'):         tag.replacewith('')         link=tag     link=name_box.find_all('a')     k=0     while k<len(link):         print link[k]         k+=1 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -