Posts

Showing posts from January, 2018

微信公众号爬虫笔记

1. 使用Selenium启动web browser driver从而通过程序模拟web application在web browser上的操作。一般来说,selenium是用于测试web application的操作, 在这里使用selenium模拟人为操作登陆微信公众平台从而获取cookies。 使用步骤:     a. Selenium 下载安装包     b. Google developer site下载 chromdriver.exe. 需要注意的是在mac环境下,安装的时候需要使用sudo(admin权限) ,并且为了使python能够识别chromedriver.exe, 需要把这个执行文件放置于Library/Python/2.6/site-package下面。 第一部分代码 from selenium import webdriver import time import json from pprint import pprint post = {} driver = webdriver.Chrome('/Library/Python/2.7/site-packages/selenium/webdriver/chromedriver') driver.get('https://mp.weixin.qq.com/') time.sleep(2) driver.find_element_by_name("account").clear() driver.find_element_by_name("account").send_keys('账号') driver.find_element_by_name("password").clear() driver.find_element_by_name("password").send_keys('密码') time.sleep(5) driver.find_element_by_xpath("//a[@class='btn_login']").click() time.sleep(15) driver.

如何写好 markdown 文档

http://markdown.tw/

Std::string operation

#include <string> string can be regarded as a vector of char 1. length() 2.  Element access:      [], at(_index), front(), back() 3. modifier     a. insert(pos, char*), insert(pos, string str)     b. c_str -> get char*[]     c. +, push_back() --> append         pop_back()     d. erase(pos, int len)     e.