随笔分类 - python
摘要:import scrapy from xxxx.items import XXXXItem from scrapy.http.request import Request class ZndsSpider(scrapy.spiders.Spider): name = "xxxx" allowed_domains = ["xxxx.com"] start_urls=[] ...
阅读全文
posted @ 2016-12-30 18:30
fj0716
摘要:根据某地每月的平均温度[17, 19, 21, 28, 33, 38, 37, 37, 31, 23, 19, 18]拟合温度函数。 scipy.optimize提供了函数最小值(标量或多维)、曲线拟合和寻找等式的根的有用算法。 因为温度是以年为单位的 可以看出温度是以周期为12的正弦函数 构建函数
阅读全文
posted @ 2016-10-14 16:35
fj0716
摘要:Python3对文本(str)和二进制数据(bytes)作了更为清晰的区分。 文本默认是以Unicode编码(python2默认是ascii),由str类型表示,二进制数据则由bytes类型表示。 str是文本类型,即str类型 bytes()函数同str.encode(),即把str类型编码为by
阅读全文
posted @ 2016-03-12 20:50
fj0716
摘要:print(value,sep=' ',end='\n',file=sys.stdout, flush=False) sep=' '默认空格 print('hello','world') #hello world print('hello','world',sep='|') #hello|world
阅读全文
posted @ 2016-02-26 22:18
fj0716
摘要:string.ascii_lowercase ='abcdefghijklmnopqrstuvwxyz' string.ascii_uppercase ='ABCDEFGHIJKLMNOPQRSTUVWXYZ' string.ascii_letters ='abcdefghijklmnopqrstu
阅读全文
posted @ 2016-02-26 20:38
fj0716
摘要:random.random() 返回[0,1)之间的浮点数 random.randrange(stop) / random.randrange(start,stop[,step]) 返回[0,stop) / [start,stop)且步长为step的整数 random.randint(start,s
阅读全文
posted @ 2016-02-26 17:37
fj0716
摘要:这关较第三关难度增加许多,主要多了并发编程 密码一共有100位,分布在13页,每页打开的时间在15秒左右,所以理所当然的想到要用并发,但是后来发现同IP访问间隔时间不能小于8秒,不然会返回404,所以最好是代理+并发。 目前没有做代理,以后有时间在重新写,由于密码位置上随机出现的,所以采集到页数要远
阅读全文
posted @ 2016-02-02 14:10
fj0716
摘要:第三关,先登录,再猜密码,这关难度较第二关大幅增加,要先去注册一个登录账号,然后打开F12,多登录几次,观察headers数据的变化 给出代码,里面注释很详细 import urllib.request as ur import urllib.parse as up import http.cook
阅读全文
posted @ 2016-01-27 15:42
fj0716
摘要:第二关猜登录密码,需要用到urllib.request和urllib.parse 也很简单,给代码 import urllib.request as ur import urllib.parse as up import re url='http://www.heibanke.com/lesson/
阅读全文
posted @ 2016-01-27 15:35
fj0716
摘要:这是学习python爬虫练习很好的网站,强烈推荐! 地址http://www.heibanke.com/lesson/crawler_ex00/ 第一关猜数字 很简单,直接给出代码 import urllib.request as ur import re url='http://www.heiba
阅读全文
posted @ 2016-01-27 15:33
fj0716
摘要:urllib.requestimport urllib.request as ururl='http://ie.icoa.cn'user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'req=ur.Request(url)req.ad...
阅读全文
posted @ 2016-01-18 09:51
fj0716

浙公网安备 33010602011771号