Use ghost.py to crawl the information of a micro-letter public account by searching for a micro-letter search
#-*-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
The above is the entire content of this article, I hope to learn Python can help