您现在的位置是:Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款 >
02 python爬取買粉絲買粉絲數據(Python豆瓣電影《肖申克的救贖》評論爬取)
Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款2024-06-15 07:20:11【】9人已围观
简介p;time import re import json import os cl
import re
import json
import os
class weixin_spider:
def __init__(self, kw):
' 構造函數 '
self.kw = kw
# 搜狐買粉絲搜索鏈接
#self.sogou_search_url = '買粉絲://weixin.sogou.買粉絲/weixin?type=1&query=%s&ie=utf8&_sug_=n&_sug_type_=' % quote(self.kw)
self.sogou_search_url = '買粉絲://weixin.sogou.買粉絲/weixin?type=1&query=%s&ie=utf8&s_from=input&_sug_=n&_sug_type_=' % quote(self.kw)
# 爬蟲偽裝
self.headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 FirePHP/0refox/47.0 FirePHP/0.7.4.1'}
# 操作超時時長
self.timeout = 5
self.s = requests.Session()
def get_search_result_by_kw(self):
self.log('搜索地址為:%s' % self.sogou_search_url)
return self.s.get(self.sogou_search_url, headers=self.headers, timeout=self.timeout).買粉絲ntent
def get_wx_url_by_sougou_search_買粉絲(self, sougou_search_買粉絲):
' 根據返回sougou_search_買粉絲,從中獲取買粉絲主頁鏈接 '
doc = pq(sougou_search_買粉絲)
#print doc('p[class="tit"]')('a').attr('href')
#print doc('div[class=img-box]')('a').attr('href')
#通過pyquery的方式處理網頁內容,類似用beautifulsoup,但是pyquery和jQuery的方法類似,找到買粉絲主頁地址
return doc('div[class=txt-box]')('p[class=tit]')('a').attr('href')
def get_selenium_js_買粉絲(self, wx_url):
' 執行js渲染內容,并返回渲染后的買粉絲內容 '
browser = webdriver.PhantomJS()
browser.get(wx_url)
time.sleep(3)
# 執行js得到整個dom
買粉絲 = browser.execute_script("return document.documentElement.outerHTML")
return 買粉絲
def parse_wx_articles_by_買粉絲(self, selenium_買粉絲):
' 從selenium_買粉絲中解析出買粉絲買粉絲文章 '
doc = pq(selenium_買粉絲)
return doc('div[class="weui_msg_card"]')
def switch_arctiles_to_list(self, articles):
' 把articles轉換成數據字典 '
articles_list = []
i = 1
if articles:
for article in articles.items():
self.log(u'開始整合(%d/%d)' % (i, len(articles)))
articles_list.append(self.parse_one_article(article))
i += 1
# break
return articles_list
def parse_one_article(self, article):
' 解析單篇文章 '
article_dict = { }
article = article('.weui_media_box[id]')
title = article('h4[class="weui_media_title"]').text()
self.log('標題是: %s' % title)
url = '買粉絲://mp.weixin.qq.買粉絲' + article('h4[class="weui_media_title"]').attr('hrefs')
self.log('地址為: %s' % url)
summary = article('.weui_media_desc').text()
self.log('文章簡述: %s' % summary)
date = article('.weui_media_extra_info').text()
self.log('發表時間為: %s' % date)
pic = self.parse_買粉絲ver_pic(article)
買粉絲ntent = self.parse_買粉絲ntent_by_url(url).買粉絲()
買粉絲ntentfiletitle=self.kw+'/'+title+'_'+date+'.買粉絲'
self.save_買粉絲ntent_file(買粉絲ntentfiletitle,買粉絲ntent)
return {
'title': title,
'url': url,
'summary': summary,
'date': date,
'pic':&n
很赞哦!(4583)
相关文章
- 01 01 北京幫粉絲買車砍價(為什么身邊的90后都在買二手車安全嗎)
- 01 01 買菜燉粉絲(豬肉燉粉條的做法?)
- 01 01 從來不買周邊的粉絲算粉絲嗎(如何看待嚴浩翔開玩笑說賣頭發給粉絲?)
- 01 01 買車幫武漢粉絲砍價(我想了解汽車代砍價是真的嗎?)
- 01 01 博主去華強北給粉絲買東西(華強北帶貨主播哪個比較靠譜)
- 01 01 買配方做視頻給粉絲(新手視頻剪輯怎么賺錢需要多少粉絲)
- 01 01 聽粉絲說買什么就買什么(主播求關注的精辟語錄求粉絲關注的順口溜)
- 03 中國民營外貿企業100強(2021國內貿易企業排名前十是哪些)
- 03 中國海外保險業務發展現狀(中國出口信用保險的現狀)
- 01 01 買車找粉絲幫忙(網上很多的車評人,都會幫粉絲低價買車,他們是在作秀嗎?)
热门文章
站长推荐
01 01 偶像該不該為粉絲買單(偶像是否應該為粉絲行為買單?為什么?)
01 01 偶遇粉絲買零食(我發情感語錄有粉絲,然后掛小黃車賣零食會有人買嗎,畢竟針對用戶不一樣)
03 中國服務貿易競爭力分析的參考文獻有哪些(中國加入世界貿易組織,面臨經濟全球化,將會遇到什么問題?我們應該如何應對?尤其是銀行業應該怎樣改制)
03 中國最賺錢的網紅球員(你知道CBA吸金能力最強的5大球星都是誰嗎?)
01 01 買車幫粉絲砍價臨沂(買車從網上,和小紅書上面的人幫忙提車,砍價提車靠譜嗎?)
01 01 吐槽網絡上的人幫粉絲買車(為啥每次買車周圍都有好多人,吐槽自己選的車型各種不好?)
01 01 做粉絲要買什么(粉絲什么牌子好)
01 01 什么是粉絲行為偶像買單(粉絲行為,偶像買單是神馬?)