Python3 Simple realization of micro-trust crawler _python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.