Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
guppy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Svetlana Tkachenko
guppy
Commits
026dbc53
Commit
026dbc53
authored
14 years ago
by
Svetlana Tkachenko
Browse files
Options
Downloads
Patches
Plain Diff
added 'web' module; added 'ddg' command
parent
8de65083
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
m_web.py
+38
-0
38 additions, 0 deletions
m_web.py
with
38 additions
and
0 deletions
m_web.py
0 → 100644
+
38
−
0
View file @
026dbc53
# Copyright 2010, 2011 G24
#
# This file is part of gpy.
#
# gpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# gpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gpy. If not, see <http://www.gnu.org/licenses/>.
import
main
import
urllib
import
json
class
mod_main
(
main
.
clisten
):
"""
Web module.
"""
def
addcmds
(
self
):
self
.
name
=
"
web
"
self
.
cmds
=
{
"
ddg
"
:
"
ddg
"
}
def
ddg
(
self
):
'''
www.duckduckgo.com web search.
'''
try
:
request
=
self
.
conn
.
recvinfo
[
"
message.params
"
].
replace
(
"
"
,
"
+
"
)
sock
=
urllib
.
urlopen
(
"
http://api.duckduckgo.com/?q=%s&o=json
"
%
request
)
data
=
sock
.
read
()
sock
.
close
()
self
.
conn
.
reply
(
json
.
loads
(
data
)[
"
Definition
"
])
except
Exception
,
e
:
self
.
conn
.
reply
(
str
(
e
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment