最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python3簡(jiǎn)單實(shí)現(xiàn)微信爬蟲

 更新時(shí)間:2015年04月09日 11:49:15   投稿:hebedich  
我們可以通過(guò)python 來(lái)實(shí)現(xiàn)這樣一個(gè)簡(jiǎn)單的爬蟲功能,把我們想要的代碼爬取到本地。下面就看看如何使用python來(lái)實(shí)現(xiàn)這樣一個(gè)功能。

使用ghost.py 通過(guò)搜搜 的微信搜索來(lái)爬取微信公共賬號(hào)的信息

# -*- 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

以上所述就是本文的全部?jī)?nèi)容了,希望對(duì)大家學(xué)習(xí)Python能夠有所幫助

相關(guān)文章

最新評(píng)論

麻阳| 双柏县| 无棣县| 固镇县| 敦煌市| 深水埗区| 武宁县| 若羌县| 绥芬河市| 泰宁县| 富裕县| 连云港市| 无锡市| 平江县| 阳谷县| 新昌县| 敦化市| 东城区| 肃北| 论坛| 二手房| 永昌县| 荔波县| 象山县| 西贡区| 兴业县| 白山市| 油尖旺区| 洪雅县| 抚顺市| 谢通门县| 宣汉县| 肇源县| 陇川县| 彭泽县| 体育| 海淀区| 内乡县| 舞阳县| 镇巴县| 虞城县|