Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's another solution, this time back in python-land. This was put together by Tom De Smedt, author of the <a href="http://www.clips.ua.ac.be/pages/pattern" rel="nofollow">Pattern</a> web-mining kit.</p> <p>I'll communicate with the author of <code>python-oauth2</code> to see if it can be fixed.</p> <pre><code>OAUTH_CONSUMER_KEY = "blahblahblah" OAUTH_CONSUMER_SECRET = "blah" import urllib import hmac import time import random import base64 try: from hashlib import sha1 from hashlib import md5 except: import sha as sha1 import md5; md5=md5.new def hmac_sha1(key, text): return hmac.new(key, text, sha1).digest() def oauth_nonce(length=40): h = "".join([str(random.randint(0, 9)) for i in range(length)]) h = md5(str(time.time()) + h).hexdigest() return h def oauth_timestamp(): return str(int(time.time())) def oauth_encode(s): return urllib.quote(s, "~") def oauth_signature(url, data={}, method="get", secret="", token=""): # Signature base string: http://tools.ietf.org/html/rfc5849#section-3.4.1 base = oauth_encode(method.upper()) + "&amp;" base += oauth_encode(url.rstrip("?")) + "&amp;" base += oauth_encode("&amp;".join(["%s=%s" % (k, v) for k, v in sorted(data.items())])) # HMAC-SHA1 signature algorithm: http://tools.ietf.org/html/rfc5849#section-3.4.2 signature = hmac_sha1(oauth_encode(secret) + "&amp;" + token, base) signature = base64.b64encode(signature) return signature q = "cat" url = "http://yboss.yahooapis.com/ysearch/" + "web" # web | images | news data = { "q": q, "start": 0, "count": 50, # 35 for images "format": "xml", "oauth_version": "1.0", "oauth_nonce" : oauth_nonce(), "oauth_timestamp" : oauth_timestamp(), "oauth_consumer_key" : OAUTH_CONSUMER_KEY, "oauth_signature_method" : "HMAC-SHA1", } data["oauth_signature"] = oauth_signature(url, data, secret=OAUTH_CONSUMER_SECRET) complete_url = url + "?" + urllib.urlencode(data) response = urllib.urlopen(complete_url) print response.read() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload