本文整理汇总了Python中spider.Spider.setworkdir方法的典型用法代码示例。如果您正苦于以下问题:Python Spider.setworkdir方法的具体用法?Python Spider.setworkdir怎么用?Python Spider.setworkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spider.Spider
的用法示例。
在下文中一共展示了Spider.setworkdir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Spider
# 需要导入模块: from spider import Spider [as 别名]
# 或者: from spider.Spider import setworkdir [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')