i wrote the following code for extracting the all no. from the web page & add all of them.but i want to code it without using regular expression so, please Guid me how to do it. link:http://ift.tt/2s0hyP3
my code :
import urllib
import re
from BeautifulSoup import *
html = urllib.urlopen('http://ift.tt/2s0hyP3 ').read()
soup = BeautifulSoup(html)
# Retrieve all of the anchor tags
tags = soup('td')
total = 0
for tag in tags:
# Look at the parts of a tag
line = str(tag)
x = re.findall('[0-9]+',line)
if len(x) > 0:
for item in x:
total += int(item)
print(total)
Aucun commentaire:
Enregistrer un commentaire