python制作最美應(yīng)用的爬蟲
更新時間:2015年10月28日 08:57:40 作者:土豆去哪了
這篇文章主要介紹了python制作最美應(yīng)用的爬蟲的相關(guān)資料,需要的朋友可以參考下
安卓最美應(yīng)用頁面爬蟲,爬蟲很簡單,設(shè)計的東西到挺多的
文件操作
正則表達(dá)式
字符串替換等等
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')
您可能感興趣的文章:
- python模擬新浪微博登陸功能(新浪微博爬蟲)
- Python爬蟲框架Scrapy安裝使用步驟
- python抓取網(wǎng)頁圖片示例(python爬蟲)
- 使用Python編寫簡單網(wǎng)絡(luò)爬蟲抓取視頻下載資源
- 零基礎(chǔ)寫python爬蟲之使用urllib2組件抓取網(wǎng)頁內(nèi)容
- 零基礎(chǔ)寫python爬蟲之爬蟲編寫全記錄
- 零基礎(chǔ)寫python爬蟲之使用Scrapy框架編寫爬蟲
- Python實現(xiàn)抓取頁面上鏈接的簡單爬蟲分享
- python3簡單實現(xiàn)微信爬蟲
- python編寫爬蟲小程序
- 基python實現(xiàn)多線程網(wǎng)頁爬蟲
- Python制作爬蟲采集小說
- python制作花瓣網(wǎng)美女圖片爬蟲
相關(guān)文章
如何優(yōu)雅地處理Django中的favicon.ico圖標(biāo)詳解
默認(rèn)情況下,瀏覽器訪問一個網(wǎng)站的時候,同時還會向服務(wù)器請求"/favicon.ico"這個URL,目的是獲取網(wǎng)站的圖標(biāo),下面這篇文章主要給大家介紹了關(guān)于如何優(yōu)雅地處理Django中favicon.ico圖標(biāo)的相關(guān)資料,需要的朋友可以參考下2018-07-07python創(chuàng)建學(xué)生成績管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了python創(chuàng)建學(xué)生成績管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-11-11