Skip to content

Instantly share code, notes, and snippets.

@swshan
swshan / crawler.r.2.6.py
Created November 25, 2015 01:44
data grab script
#-*- coding:utf-8 -*-
"""
Date 15-11-11 lastest progres
"""
import time
import sys
import re
@swshan
swshan / crawler.r.2.4.py
Last active November 11, 2015 03:29
modify at the date of 11.11, for purpose of Coupling
#-*- coding:utf-8 -*-
"""
Date 15-11-11 lastest progres
"""
import time
import sys
import re
import gevent
@swshan
swshan / test-01.py
Created November 10, 2015 15:23
Learning Python example for argument
#coding=utf-8
def function_get_args(a,b,c):
print a,b,c
return_val = a * 5
return return_val
def function_get_args_return_tuple(a,b,c):
print a,b,c
@swshan
swshan / rc2.py
Created November 8, 2015 09:28
数据抓取 的小改进版本 脚本 主要改了 gevent spawn
#-*- coding:utf-8 -*-
''' For avoiding keyerror '''
from gevent import monkey
monkey.patch_all()
import gevent
import sys
import re
# coding=UTF-8
import urllib2
import optparse
from bs4 import BeautifulSoup
from urlparse import urlsplit
from os.path import basename
from PIL import Image
from PIL.ExifTags import TAGS
def findImages(url):
@swshan
swshan / script_01.py
Created November 7, 2015 15:07
http://zone.wooyun.org/content/23689, 获取Twitter的位置数据
# coding=UTF-8
import urllib
from anonBrowser import *
import json
import re
import urllib2
class reconPerson:
def __init__(self, handle):
self.handle = handle
@swshan
swshan / pyquery.snippet.001.py
Last active October 24, 2015 13:39
pyquery.example.001.py
''' http://blog.csdn.net/CUMT_GPF/article/details/46390509 '''
import re
import sys
import requests
from pyquery import PyQuery as pq
reload(sys)
sys.setdefaultencoding('GBK')
#fp = open("d:/result.txt",'w')
url = 'http://xlfans.com/'
#-*- coding:utf-8 -*-
import sys
import re
import requests
import gevent
from bs4 import BeautifulSoup
import urlparse
import time
#-*- coding:utf-8 -*-
import sys
import re
import requests
import gevent
from bs4 import BeautifulSoup
import urlparse
import time
import MYSQLdb
db = MYSQLdb.connect(host="localhost", #host
user="john", # username
passwd="megajonhy", #password
db="jonhydb")
# you must create a Cursor object. It will let you execute all the queries you need
cur = db.cursor()
# Use all the SQL you like