資源簡介
自動(dòng)爬取微信公眾號(hào)歷史所有文章以及封面圖片
Selenium + Chromedriver
代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
from?selenium?import?webdriver
import?time
import?json
import?requests
import?re
import?random
#微信公眾號(hào)賬號(hào)
user=“bigdataservice@cisdi.com.cn“
#公眾號(hào)密碼
password=“302clubEasyData“
#設(shè)置要爬取的公眾號(hào)列表
gzlist=[‘東方國信‘]
#登錄微信公眾號(hào),獲取登錄之后的cookies信息,并保存到本地文本中
def?weChat_login():
????#定義一個(gè)空的字典,存放cookies內(nèi)容
????post={}
????#用webdriver啟動(dòng)谷歌瀏覽器
????print(“啟動(dòng)瀏覽器,打開微信公眾號(hào)登錄界面“)
????driver?=?webdriver.Chrome(executable_path=r‘D:\360安全瀏覽器下載\chromedriver_win32\chromedriver.exe‘)
????#打開微信公眾號(hào)登錄頁面
????driver.get(‘https://mp.weixin.qq.com/‘)
????#等待5秒鐘
????time.sleep(5)
????print(“正在輸入微信公眾號(hào)登錄賬號(hào)和密碼......“)
????#清空賬號(hào)框中的內(nèi)容
????driver.find_element_by_xpath(‘//*[@id=“header“]/div[2]/div/div/form/div[1]/div[1]/div/span/input‘).clear()
????#自動(dòng)填入登錄用戶名
????driver.find_element
評(píng)論
共有 條評(píng)論