By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,688 Members | 1,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,688 IT Pros & Developers. It's quick & easy.

Sending information to a website

P: n/a
Okay, so what I want to do is connect to dictionary.com and send the
website a word, and later receive the definition. But for now, I want
to focus on sending the word. A good guy from this mailing list said I
should look into the code and then figure out what the word you want
to be defined is called by the website. In other words, what is the
name of the word the user inputs. Okay, so using the firebug extension
I got the code that the search field on the website uses. here is that
code.

<div id="search">
<form onsubmit="return formcheck();" action="/search" method="get"
name="search_form">
<input id="search-terms" class="text" type="text" maxlength="256"
value="" name="q"/>

Anyway, not to get to complicated. How would any of you suggest I send
this word to the site. While bearing in mind that I will need to
return it if it matters for this step.

Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Jim
One way is to use a package that allows you to simulate being a
browser:
http://wwwsearch.sourceforge.net/mechanize/
..

Jun 27 '08 #2

P: n/a
On Jun 24, 12:13 am, Alex Bryan <alexnbr...@gmail.comwrote:
Okay, so what I want to do is connect to dictionary.com and send the
website a word, and later receive the definition. But for now, I want
to focus on sending the word. A good guy from this mailing list said I
should look into the code and then figure out what the word you want
to be defined is called by the website. In other words, what is the
name of the word the user inputs. Okay, so using the firebug extension
I got the code that the search field on the website uses. here is that
code.

<div id="search">
<form onsubmit="return formcheck();" action="/search" method="get"
name="search_form">
<input id="search-terms" class="text" type="text" maxlength="256"
value="" name="q"/>

Anyway, not to get to complicated. How would any of you suggest I send
this word to the site. While bearing in mind that I will need to
return it if it matters for this step.
You should be able to automate the submission via urllib.urlopen. On
success, that call will return a file-like object that contains the
response HTML code. You do need to be a bit careful when 'screen
scraping' as many sites have terms of service agreements that
explicitly deny automating requests.

Once you've got the HTML back, you'll need to pull the definition out.
Look at BeautifulSoup.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.