Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > More on Urllib, and Urllib2

Reply
Thread Tools

More on Urllib, and Urllib2

 
 
Alex Bryan
Guest
Posts: n/a
 
      06-27-2008
Okay, so I am having issues figuring anything out about this and have
read the "missing manual" about it so please don't send me that link
again. To put it simply I want to be able to input a word and get the
definition from dictionary.com. Now I found a work-around for
searching for the word, I just make it in the actual address. For
example I want to search for cheese, I can just do a:

urllib2.urlopen("http://dictionary.reference.com/browse/cheese")

However, the actual definition is in javascript on the page. I used
firebug to see it, and the first def, looks like this:

<table class="luna-Ent">
<tbody>
<tr>
<td class="dn" valign="top">1.</td>
<td valign="top">the curd of milk separated from the whey and prepared
in many ways as a food. </td>

the problem being that if I use code like this to get the html of that
page in python:

response = urllib2.urlopen("the webiste....")
html = response.read()
print html

I get the html source of the page, but no table with my definitions.
So what can I do? Also, is there a book or a better tutorial or
explanation of this urllib2, and urllib? If so, PLEASE let me know
about it; I will be eternally grateful.

 
Reply With Quote
 
 
 
 
CracKPod
Guest
Posts: n/a
 
      06-28-2008
On 28 Jun., 01:42, Alex Bryan <alexnbr...@gmail.com> wrote:
> Okay, so I am having issues figuring anything out about this and have *
> read the "missing manual" about it so please don't send me that link *
> again. To put it simply I want to be able to input a word and get the *
> definition from dictionary.com. Now I found a work-around for *
> searching for the word, I just make it in the actual address. For *
> example I want to search for cheese, I can just do a:
>
> urllib2.urlopen("http://dictionary.reference.com/browse/cheese")
>
> However, the actual definition is in javascript on the page. I used *
> firebug to see it, and the first def, looks like this:
>
> <table class="luna-Ent">
> <tbody>
> <tr>
> <td class="dn" valign="top">1.</td>
> <td valign="top">the curd of milk separated from the whey and prepared *
> in many ways as a food. </td>
>
> the problem being that if I use code like this to get the html of that *
> page in python:
>
> response = urllib2.urlopen("the webiste....")
> html = response.read()
> print html
>
> I get the html source of the page, but no table with my definitions. *
> So what can I do? Also, is there a book or a better tutorial or *
> explanation of this urllib2, and urllib? If so, PLEASE let me know *
> about it; I will be eternally grateful.


It would probably be a good idea to take a look at mechanize:
http://wwwsearch.sourceforge.net/mechanize/
and at BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/

Greetz,
CracKPod
 
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
Kamaelia 0.4.0 RELEASED - Faster! More Tools! More Examples! More Docs! ;-) Michael Python 4 06-26-2006 08:00 AM
With a Ruby Yell: more, more more! Robert Klemme Ruby 5 09-29-2005 06:37 AM
Problem with: urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) Josef Cihal Python 0 09-05-2005 11:26 AM
urllib2 - basic authentication and the put and delete methods news.corp.adobe.com Python 1 07-08-2005 10:40 AM
More than one cookie with urllib2 Rafael T. Ugolini Python 7 12-23-2003 07:53 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