Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Parsing

Reply
Thread Tools

Parsing

 
 
Michael
Guest
Posts: n/a
 
      07-10-2003
I have been assigned a project to parse a webpage for data using
Python. I have finished only basic tutorials. Any suggestions as to
where I should go from here? Thanks in advance.
 
Reply With Quote
 
 
 
 
Simon Bayling
Guest
Posts: n/a
 
      07-10-2003
(Michael) wrote in
news: om:

> I have been assigned a project to parse a webpage for data using
> Python. I have finished only basic tutorials. Any suggestions as to
> where I should go from here? Thanks in advance.
>


Parsing? What are you looking for?
Do you have to download the page as well?

If it's a fairly simple thing to find, you could use something like;

>>> import urllib
>>> source = urllib.urlopen("http://www.google.com").readlines()
>>> for line in source:
>>> if line.find("logo.gif") > -1:
>>> print "Found google logo"


If the data to find is more complicated, or you need to parse the HTML as
well, you should look at more string methods, maybe regular expressions
(import re)...

Cheers,
Simon.
 
Reply With Quote
 
 
 
 
Peter van Kampen
Guest
Posts: n/a
 
      07-10-2003
In article < >, Michael wrote:
> I have been assigned a project to parse a webpage for data using
> Python. I have finished only basic tutorials. Any suggestions as to
> where I should go from here? Thanks in advance.



Try to be a little more specific. Parse for what? Links? Images? Tags?

Anyway. A good start might be the HTMLParser that comes with the
batteries since 2.2 if I remember correctly. See

http://www.python.org/doc/current/li...r-example.html

for a tiny example.

PterK

--
Peter van Kampen
pterk -- at -- datatailors.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What libraries should I use for MIME parsing, XML parsing, and MySQL ? John Levine Ruby 0 02-02-2012 11:15 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 09:01 PM
[ANN] Parsing Tutorial and YARD 1.0: A C++ Parsing Framework Christopher Diggins C++ 0 07-09-2007 08:58 PM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
Perl expression for parsing CSV (ignoring parsing commas when in double quotes) GIMME Perl 2 02-11-2004 05:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57