當前位置: 首頁>>代碼示例>>Python>>正文


Python Embedly.extract方法代碼示例

本文整理匯總了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"
開發者ID:wfrick,項目名稱:factionapp,代碼行數:28,代碼來源:utilities.py

示例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
開發者ID:nicolezhu,項目名稱:socialite,代碼行數:15,代碼來源:api.py

示例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)
開發者ID:DjangoLover,項目名稱:allmywishes,代碼行數:6,代碼來源:utils.py

示例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
開發者ID:Jonnyd55,項目名稱:FIleThis,代碼行數:8,代碼來源:enrichment.py

示例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)
開發者ID:nicolezhu,項目名稱:socialite,代碼行數:31,代碼來源:getarticle.py


注:本文中的embedly.Embedly.extract方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。