本文整理匯總了Python中embedly.Embedly.extract方法的典型用法代碼示例。如果您正苦於以下問題:Python Embedly.extract方法的具體用法?Python Embedly.extract怎麽用?Python Embedly.extract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類embedly.Embedly
的用法示例。
在下文中一共展示了Embedly.extract方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: embedly_link
# 需要導入模塊: from embedly import Embedly [as 別名]
# 或者: from embedly.Embedly import extract [as 別名]
def embedly_link(URL):
#Takes a URL, returns a populated Link object
#Returns "error" if Embedly API fails
client = Embedly(embedly_key)
response = client.extract(URL)
try:
#Get link information from Embedly
headline = response['title']
URL = clean_url(response['url'])
summary = response['description']
source = response['provider_name']
path = page_path(headline)
keywords_response = response['keywords']
keyword1 = str(keywords_response[0]['name'])
keyword2 = str(keywords_response[1]['name'])
keyword3 = str(keywords_response[2]['name'])
keyword4 = str(keywords_response[3]['name'])
keyword5 = str(keywords_response[4]['name'])
#Create Link object with info from Embedly
link = Link(headline = headline, url = URL, source = source, summary = summary,
path = path, keyword1 = keyword1, keyword2 = keyword2, keyword3 = keyword3,
keyword4 = keyword4, keyword5 = keyword5, votes = 0)
return link
except:
return "error"
示例2: get_article
# 需要導入模塊: from embedly import Embedly [as 別名]
# 或者: from embedly.Embedly import extract [as 別名]
def get_article():
url = request.args.get('url')
client = Embedly('f2f84ff5013b443ab711b204590d9aa2')
result = client.extract(url)
article = {}
article["url"] = result["url"]
article["headline"] = result["title"]
article["description"] = result["description"]
article["content"] = result["content"]
response = make_response(json.dumps(article, indent=4))
response.headers['Access-Control-Allow-Origin'] = "*"
return response
示例3: __init__
# 需要導入模塊: from embedly import Embedly [as 別名]
# 或者: from embedly.Embedly import extract [as 別名]
def __init__(self, url):
self.url = url
client = Embedly(settings.EMBEDLY_API_KEY)
self.obj = client.extract(self.url)
示例4: enrich
# 需要導入模塊: from embedly import Embedly [as 別名]
# 或者: from embedly.Embedly import extract [as 別名]
def enrich(url, title):
client = Embedly(EMBEDLY_KEY)
data = client.extract(url)
data['text'] = SmartHTMLDocument("<html><body>%s</body></html>" % data['content']).getText().strip()
data['summary'] = Summarizer(data['text'], title).summary()
return data
示例5: Embedly
# 需要導入模塊: from embedly import Embedly [as 別名]
# 或者: from embedly.Embedly import extract [as 別名]
# using embedly with python
import csv
import itertools
import json
import requests
from urlparse import urljoin
# below currently works in the command line, but not sure how to translate it into this python document, run it and have it work
from embedly import Embedly
# key = 'f2f84ff5013b443ab711b204590d9aa2'
client = Embedly('f2f84ff5013b443ab711b204590d9aa2')
result = client.extract('https://medium.com/message/yes-to-the-dress-5ec06c06aca4')
article = {}
article["url"] = result["url"]
article["headline"] = result["title"]
article["description"] = result["description"]
article["content"] = result["content"]
print "URL:", result["url"]
print "Headline:", result["title"]
print "Description:", result["description"]
print "Article:", result["content"]
subjects_file = open("../articles/dressarticle.json", "w")
print >> json.dump(article, subjects_file, indent=4)