抓取应届生的职位信息的代码

抓取应届生的职位信息的代码如下:(前五页)
  1. #!/usr/bin/env python
  2.  
  3. __author__ "Dan Deng (sixu05202004@gmail.com)"
  4. __version__ "0.1.0"
  5. __copyright__ "Copyright (c) 2011-2012 Dan"
  6. __license__ "New-style BSD"
  7.  
  8. from BeautifulSoup import BeautifulSoup
  9. import reurllib2pickle
  10.  
  11.  
  12. pattern=re.compile('/job-001.*')
  13. num=0
  14. test={}
  15.  
  16. for i in range(1,6):
  17.     url='http://www.yingjiesheng.com/beijing-morebbsjob-'+str(i)+'.html'
  18.     pagesource=urllib2.urlopen(url)
  19.     soup=BeautifulSoup(pagesource)
  20.     result=soup.findAll('a',href=pattern)
  21.     for j in range(0,len(result)):
  22.         test[str(result[j]['href'])]=str(result[j].string)
  23.     soup.clear()
  24.         
  25. f=open('D:temp1.plk','rb')
  26. test2=pickle.load(f)
  27. f.close()
  28.  
  29. for eachline in test.iterkeys():
  30.     if eachline not in test2.iterkeys():
  31.         print 'http://www.yingjiesheng.com'+eachline,test[eachline].decode('utf-8').encode('utf-8')
  32.         num+=1
  33.  
  34. print "the count of update jobs is %d" num
  35.         
  36.  
  37.  
  38. if num:
  39.     f=open('D:temp1.plk','wb')
  40.     pickle.dump(test,f,-1)
  41.  
  42.     f.close()
  43.  
  44.  
  45.  
  46. #        for eachinle in result:
  47. #            if eachline not in joblist:
  48. #                joblist.append()
7.31号的结果类似如下: http://www.yingjiesheng.com/job-001-117-934.html [北京]北京人民艺术剧院2011招聘应届大学毕业生  http://www.yingjiesheng.com/job-001-118-753.html [北京]IBM GPS诚聘BAO Solution Developer|Lead http://www.yingjiesheng.com/job-001-118-341.html [北京]北京北阳电子招聘图形视频方向软件工程师 http://www.yingjiesheng.com/job-001-118-788.html [北京]互联网公司急聘J2EE后台开发高级工程师|市场营销 http://www.yingjiesheng.com/job-001-118-356.html [北京]北京成府工业新科技研究院2011招聘  http://www.yingjiesheng.com/job-001-117-822.html [北京]招聘Web前台开发工程师 http://www.yingjiesheng.com/job-001-118-767.html [北京]某保险公司总部招聘数据分析人员 。。。。。。