|
最近在研究爬虫:
主要是2个版本 C# , Python
首先: 我们的爬虫是用在游戏客户端上,大概的需求就是 服务器是web形式的,每天去点点总是很烦人,所以写一个web客户端
httpwatch抓包,分析包。
Python 部分研究可行性代码,没有封装
!# 请求服务器部分 ,研究可行性部分,未封装
###########################################################
#
#
# iQSRobots
# 使用范围:Python3 + T4
#
#
__author__ = "Eagle Zhao(eaglezzb@gmail.com"
__version__ = "$Revision: 1.0 $"
__date__ = "$Date: 2011/11/15 21:57:19 $"
__copyright__ = "Copyright (c) 2011 Eagle"
__license__ = "iQS"
###########################################################
import urllib.parse
import httplib2
http = httplib2.Http()
url = 'http://ts2.travian.tw/dorf1.php'
body = {'name': '小铃铛','password':'1838888','s1':'登陆','w':'1280:800','login': '1321368625'}
headers = {'Content-type': 'application/x-www-form-urlencoded'}
response, content = http.request(url, 'POST', headers=headers, body=urllib.parse.urlencode(body))
#print(urllib.parse.urlencode(body))
print(response)
headers = {'Cookie': response['set-cookie']}
url = 'http://ts2.travian.tw/dorf1.php'
response, content = http.request(url, 'GET', headers=headers)
#print(content.decode('utf-8'))
/// 解析HTML -==- 使用 HTMLPaser 效果不是很好,最后决定使用正则
file=open('re.xml',encoding='utf-8')
p=file.read()
import urllib.parse
import re
building_farm =[]
building_links = []
m=re.search('.+? |
|
|