使用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能夠有所幫助
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元

