当前位置:编程学习 > python >>

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()

 

补充:Web开发 , Python ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,