您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python3简单实现微信爬虫

5b51 2022/1/14 8:18:30 python 字数 1674 阅读 364 来源 www.jb51.cc/python

使用ghost.py通过搜搜的微信搜索来爬取微信公共账号的信息 #-*-coding:utf-8-*- importsys

概述

使用ghost.py 通过搜搜 的微信搜索来爬取微信公共账号的信息

# -*- coding: utf-8 -*-
import sys
reload(sys)
import datetime
import time
sys.setdefaultencoding("utf-8")
 
from ghost import Ghost
ghost = Ghost(wait_timeout=20)
 
url="http://weixin.sogou.com/gzh?openid=oIWsFt8JDv7xubXz5E3U41T0eFbk"
page,resources = ghost.open(url)
result,resources = ghost.wait_for_selector("#wxmore a")
 
from bs4 import BeautifulSoup
c=0
while True:
  if c>=30:
    break
 
  soup = BeautifulSoup(ghost.content)
 
  for wx in soup.find_all("h4"):
    print wx
 
  page,resources = ghost.evaluate(
    """
    var div1 = document.getElementById("wxBox");
    div1.innerHTML = '';
    """)
  ghost.click("#wxmore a")
  result,resources = ghost.wait_for_selector(".wx-rb3")
 
  c=c+1
  pass

以上所述就是本文的全部内容了,希望对大家学习Python能够有所帮助

总结

以上是编程之家为你收集整理的python3简单实现微信爬虫全部内容,希望文章能够帮你解决python3简单实现微信爬虫所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶