python test0729.py










 

#!/usr/env  python
#-*- coding: utf-8  -*-
import urllib 
import urllib2 
import random 
import requests
import os,sys 
import MySQLdb
from BeautifulSoup import BeautifulSoup
from sgmllib import SGMLParser 
import re
def main():
	t="https://play.google.com/store/apps/category/PERSONALIZATION"
			
	html=requests.get(t)
	result=html.content
	
	
	print type(result)
	soup=BeautifulSoup(result)
	temp=soup.prettify("utf-8")
	pattern=re.compile('<a class="title" href="(.+?)" title')
	dataresult=re.findall(pattern,temp)
	print dataresult
	print len(dataresult)
	print type(temp)
	f=file("hello.txt","w+")
	f.writelines(temp)
	f.close()
if  __name__=="__main__":
       main()


 

 

posted @ 2013-08-05 19:03  坚固66  阅读(217)  评论(0编辑  收藏  举报