• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python制作最美应用的爬虫

python制作最美应用的爬虫

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python爬虫制作,python爬虫工程师,python爬虫课程,python爬虫源码,python爬虫技术等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

安卓最美应用页面爬虫,爬虫很简单,设计的东西到挺多的
文件操作
正则表达式
字符串替换等等

import requests
import re
url = "http://zuimeia.com"
r = requests.get('http://zuimeia.com/community/app/hot/?platform=2')
pattern = re.compile(r'<a class="community-app-cover-wrapper" href="(.*?)" target="_blank">')
urlList = pattern.findall(r.content)

def requestsUrl(url):
 r = requests.get(url)
 title = re.findall(r'"app-title"><h1>(.*?)</h1>',r.content)
 #print title
 category = re.findall(r'<a class="app-tag" href="/community/app/category/title/.*?/?platform=2">(.*?)</a>',r.content)
 #print category

 describe = re.findall(r'<div id="article_content">(.*?)<div class="community-image-wrapper">',r.content)
 #print type(describe[0])
 strdescribe = srtReplace(describe[0])
 #print strdescribe

 downloadUrl = re.findall(r'<a class="download-button direct hidden" href="(.*?)"',r.content)
 #print downloadUrl

 return title,category,strdescribe,downloadUrl

def srtReplace(string):
 listReplace = ['<p>', '<br>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<h7>','<strong>','</p>', '<br/>', '</h1>', '</h2>', '</h3>', '</h4>', '</h5>',
     '</h6>', '</h7>','</strong>','<b>', '</b>']
 for eachListReplace in listReplace:
  string = string.replace(str(eachListReplace),'\n')

 string = string.replace('\n\n','')
 return string

def categornFinal(category):
 categoryFinal =''
 for eachCategory in category:
  categoryFinal = categoryFinal+str(eachCategory)+'-->'
 return categoryFinal

def urlReplace(url):
 url = url.replace('&', '&')
 return url

requestsUrl("http://zuimeia.com/community/app/27369/?platform=2")
for eachUrl in urlList:
 eachUrl = url+eachUrl
 content = requestsUrl(eachUrl)
 categoryFinal =''

 title = content[0][0]
 category = categornFinal(content[1])
 strdescribe = content[2]
 downloadUrl = urlReplace(content[3][0])

 with open('c:/wqa.txt', 'a+') as fd:
  fd.write('title:'+title+'\n'+'category:'+category+'\n'+'strdescribe:'+strdescribe+'\n'+'downloadUrl:'+downloadUrl+'\n\n\n-----------------------------------------------------------------------------------------------------------------------------\n\n\n')
</div>

</div>

您可能想查找下面的文章:

  • python制作最美应用的爬虫
  • python制作最美应用的爬虫

相关文章

  • Python读大数据txt
  • Python实现Linux命令xxd -i功能
  • python通过pil模块获得图片exif信息的方法
  • Python中的os.path路径模块中的操作方法总结
  • 简单讲解Python中的数字类型及基本的数学计算
  • python用Pygal如何生成漂亮的SVG图像详解
  • 给Python的Django框架下搭建的BLOG添加RSS功能的教程
  • python实现根据主机名字获得所有ip地址的方法
  • Python 字典与字符串的互转实例
  • 浅要分析Python程序与C程序的结合使用

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python引用DLL文件的方法
    • python列表操作使用示例分享
    • python实现登陆知乎获得个人收藏并保存为word文件
    • python中函数传参详解
    • 浅谈Python的垃圾回收机制
    • Python多线程经典问题之乘客做公交车算法实例
    • Python中文分词实现方法(安装pymmseg)
    • 利用 Monkey 命令操作屏幕快速滑动
    • 学习python之编写简单简单连接数据库并执行查询操作
    • Python ORM框架SQLAlchemy学习笔记之数据查询实例

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有