当前位置: 首页>>代码示例>>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;未经允许,请勿转载。