Struggling with this concept please help

G

George

Hello everyone I know many have helped but I cannot get this to work
out correctly. I cannot use BeautifulSoup at all. I need to:
Parse the HTML and extracting all the links, convert them to IP
addresses, and build a list of all these IP addresses, thwn I need to
sort the list and remove the duplicates so that unit testing will work.
Please help I have never done python before and I can't seem to get the
hang of it.

"""
Module to print IP addresses of tags in web file containing HTML
['0.0.0.0', '128.255.44.134', '128.255.45.54']

['0.0.0.0', '128.255.135.49', '128.255.244.57', '128.255.30.11',
'128.255.34.132', '128.255.44.51', '128.255.45.53',
'128.255.45.54', '129.255.241.42', '64.202.167.129']

"""

import htmllib
import formatter
import urllib
import socket

from urlparse import urlparse

class HTML_Parser(htmllib.HTMLParser):
def __init__(self):
htmllib.HTMLParser.__init__(self,
formatter.AbstractFormatter(formatter.NullWriter()))


def start_a(self, args):
for key, value in args:
if key.lower() == 'href':
global listURL

def showIPnums(URL):
parser = HTML_Parser()
connect = urllib.urlopen(URL)
data = connect.read()
parser.feed(data)
parser.close()
connect.close()

if __name__ == '__main__':
import doctest, sys
doctest.testmod(sys.modules[__name__])
 
G

George Sakkis

George said:
Hello everyone I know many have helped but I cannot get this to work
out correctly. I cannot use BeautifulSoup at all. I need to:
[snipped]

What do you mean you cannot use BeautifulSoup ? You cannot download it, install it, import it, or
you are not allowed to use it because it's a homework ? If it's the latter, I doubt that you'll get
a solution spelled out for you in this group.

George
 
G

George

Not allowed to use Beautiful Soup because of the very important built
ins that is provides that makes it very simple to complete this
problem. Not my choice . This is a review question for our final in two
months and I just want to get things going so I can try to understand
things better. Please help.
 
D

Diez B. Roggisch

George said:
Not allowed to use Beautiful Soup because of the very important built
ins that is provides that makes it very simple to complete this
problem. Not my choice . This is a review question for our final in two
months and I just want to get things going so I can try to understand
things better. Please help.

Post your code. Nobody is giving you the solution to your problem - it's
your task, after all! But we'd happily comment on your trials.

Diez
 
J

John Hazen

* George said:
Hello everyone I know many have helped but I cannot get this to work
out correctly.
Please help I have never done python before and I can't seem to get the
hang of it.

You posted code. Is what's in the docstring actual output? If so, what
isn't it doing that you want it to?

If it's not working correctly, what's it doing? Just saying "I cannot
get this to work" doesn't give us much to go on. If you want specific
help, be sure to:

1) post actual code
2) explain what you expect it to do
3) post actual output (or traceback)
4) ask a specific question about what you don't understand about item 3.

Even though we know this is schoolwork, I'm OK with offering you a hint
or answering a specific question.

-John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top