本文整理汇总了Python中urlobject.URLObject.endswith方法的典型用法代码示例。如果您正苦于以下问题:Python URLObject.endswith方法的具体用法?Python URLObject.endswith怎么用?Python URLObject.endswith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urlobject.URLObject
的用法示例。
在下文中一共展示了URLObject.endswith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import endswith [as 别名]
def main():
for i in range(0,1405):
for item in open('/Users/chadsahlhoff/python/ADN/appnet-logger/bin/ADNLogs/'+ str(i) +'.json','r'):
line = eval(item)
entities = line['entities']
print i
links_in_entities = entities['links']
if (len(links_in_entities) != 0):
for indices in links_in_entities:
url = indices['url']
try:
url = URLObject(url)
url = unicode(url.with_hostname(url.hostname.lower()))
except:
url = None
if url == None:
break
if url.endswith('.'):
url=url[:-1]
if url.endswith(','):
url=url[:-1]
if url.endswith('!'):
url=url[:-1]
if url.endswith('?'):
url=url[:-1]
if url.endswith('/'):
url=url[:-1]
post_id = line['id']
link = None
try:
link = hyper_links.find({'_id':url})
except:
print 'shiz its not there'
if link == None:
print 'link == None'
insert_link = {'_id':url,'count':1, 'posts':[post_id]}
hyper_links.insert(insert_link)
else:
hyper_links.update({'_id':url},{'$inc':{'count':1}, '$addToSet':{'posts':post_id}}, upsert=True)