本文整理匯總了Python中spider.Spider.getfilename方法的典型用法代碼示例。如果您正苦於以下問題:Python Spider.getfilename方法的具體用法?Python Spider.getfilename怎麽用?Python Spider.getfilename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spider.Spider
的用法示例。
在下文中一共展示了Spider.getfilename方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Spider
# 需要導入模塊: from spider import Spider [as 別名]
# 或者: from spider.Spider import getfilename [as 別名]
#!/usr/bin/env python
# coding=utf-8
from spider import Spider
spider = Spider()
spider.setworkdir('/data/work/ys/oriinfo/ownerinfo/')
spider.setfilename('owneridlist.txt')
f = open(spider.getfilename(),'r+')
while True:
dic = {}
dic['diary'] = dic['information'] = dic['allComments'] = dic['order'] = {}
line = f.readline()
if not line:
break
line = line[:-1]
print line
soup = spider.getSoup('http://www.xiaozhu.com/fangdong/' + line + '/pinglun.html')
ul = soup.find('ul',{'class':'comment_right'})
dic['allComments']['rate'] = {}
item = ['sanitationRate','descriptionRate','performanceRate','securityRate','locationRate']
if ul == None:
dic['nohtml'] = True
for i in item:
dic['allComments']['rate'][i] = 'NULL'
dic['allComments']['rate']['allcommentRate'] = 'NULL'
else:
dic['nohtml'] = False
liAll = ul.findAll('li')
cot = 0
for li in liAll:
print li
grade = li.find('span').find('em').get('value')