Re: [Tutor] html links

2007-05-25 Thread Thorsten Kampe
* max . (Mon, 14 May 2007 20:27:15 -0600)
 does anyone know of a tutorial for finding links in a web site with python.

import formatter, \
   htmllib,   \
   urllib

url = 'http://python.org'

htmlp = htmllib.HTMLParser(formatter.NullFormatter())
htmlp.feed(urllib.urlopen(url).read())
htmlp.close()

print htmlp.anchorlist

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] html links

2007-05-15 Thread Sönmez Kartal
Hi,

import urllib
from BeautifulSoup import BeautifulSoup

page = urllib.urlopen(url) # url is the page address, if you are reading 
a file in your hard drive you could use just open(filename) too, and no 
needing to urllib
soup = BeautifulSoup(page)

#links = [str(link) for link in soup.findAll('a')]
links = soup.findAll('a')

I have used list compherension, comment outed line, because findAll 
function returns a different type specific to BeautifulSoup. First line, 
list compherension used converts every link to string.

Happy coding...

-- 
Sönmez Kartal


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] html links

2007-05-15 Thread Alan Gauld

max . [EMAIL PROTECTED] wrote

 does anyone know of a tutorial for finding links in a web site with 
 python.

Beautifulsuop has been mentioned but its not part of standard python.

Her is an example of the standard library parser:

html = '''
htmlheadtitleTest page/title/head
body
center
h1Here is the first heading/h1
/center
pA short paragraph
h1A second heading/h1
pA paragraph containing a
a href=www.python.orghyperlink to python/a
/body/html
'''

from HTMLParser import HTMLParser

class H1Parser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.h1_count = 0
self.isHeading = False

def handle_starttag(self,tag,attributes=None):
if tag == 'h1':
self.h1_count += 1
self.isHeading = True

def handle_endtag(self,tag):
if tag == 'h1':
self.isHeading = False

def handle_data(self,data):
if self.isHeading and self.h1_count == 2:
print Second Header contained: , data

parser = H1Parser()
parser.feed(html)
parser.close()

 or creating files and asking ware to create a file.

I'm not sure what you mean here? Do you mean fetching a file
from a remote server? There is an ftp module if its from an ftp 
site...


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] html links

2007-05-14 Thread max .

does anyone know of a tutorial for finding links in a web site with python.

or creating files and asking ware to create a file.

thanks
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] html links

2007-05-14 Thread Luke Paireepinart
max . wrote:
 does anyone know of a tutorial for finding links in a web site with 
 python.
I believe BeautifulSoup could help with this, but am uncertain.

 or creating files and asking ware to create a file.
There are many ways to do this. The simplest would be:
filepath = raw_input(Where would you like to create the file? )
And this can vary in difficulty; if you wanted, for example, a GUI that 
lets them
browse their directory tree graphically for the file they want, you 
could do that too.

 thanks
yw
-Luke
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] HTML links from Tkinter

2005-07-15 Thread Michael Lange
On Fri, 15 Jul 2005 10:55:37 +1200 (NZST)
[EMAIL PROTECTED] wrote:


 There's no table widget in standard Tkinter.  Search in the Python Cookbook 
 (on
 ActiveState) for a MultiListbox; it might do what you need.
 
 -- 

On the Tkinter wiki there are some links to Tkinter table widgets (I have not 
tried any of these
though):

http://tkinter.unpythonic.net/wiki/Widgets

Regards

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] HTML links from Tkinter

2005-07-15 Thread Alberto Troiano
Thanks for the links
I will try both, the tktable and multilistbox

About the HTML llinks I will have to make some functions using webbrowser. I 
want to show some reports (tktable or multilistbox) but I want she to be 
able to check the same query on the web
So I think that with the GET method I can send paramaters to the page I want 
her to open

Best Regards

Alberto

From: Michael Lange [EMAIL PROTECTED]
To: tutor@python.org
Subject: Re: [Tutor] HTML links from Tkinter
Date: Fri, 15 Jul 2005 10:45:29 +0200

On Fri, 15 Jul 2005 10:55:37 +1200 (NZST)
[EMAIL PROTECTED] wrote:


  There's no table widget in standard Tkinter.  Search in the Python 
Cookbook (on
  ActiveState) for a MultiListbox; it might do what you need.
 
  --

On the Tkinter wiki there are some links to Tkinter table widgets (I have 
not tried any of these
though):

http://tkinter.unpythonic.net/wiki/Widgets

Regards

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Gaucho


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] HTML links from Tkinter

2005-07-14 Thread jfouhy
Quoting Alberto Troiano [EMAIL PROTECTED]:

 Is there any way that I can link a button to go to certain web page?
 and how can I do that?

If you want to open a web page in the user's default browser, check out the
webbrowser module in the standard library.

If you want to go to a website and suck down some data, you'll probably need
urllib (and it will be a bit more work).

 Another thing, I'll make a query by name and I want to show every
 results matching the query in a table using Tkinter.

There's no table widget in standard Tkinter.  Search in the Python Cookbook (on
ActiveState) for a MultiListbox; it might do what you need.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor