- 博客(11)
- 资源 (3)
- 收藏
- 关注
原创 python两个list转dict
In[53]: a=[1,2,3]In[54]: b=[4,5,6]In[55]: c=zip(a,b)In[57]: d={i:j for i,j in c}In[58]: dOut[58]: {1: 4, 2: 5, 3: 6}
2016-08-26 16:45:45 1330
原创 python爬去搜狐论坛笔记
今天搞了半天才搞定搜狐的爬虫,坑还蛮多的。特意记下来,方便自己下次捡起来。首先是搜狐论坛每个板块的url不一样,不能直接在得到的 【a/@href 】 加前缀。后来找到了介个,我用的是python的scrapy框架,搜狐的论坛上,每一层楼的数据是用get的方式得到的,所以response.xpath('//table[@class="viewpost"]').ext
2016-08-26 16:30:50 792
原创 python的url编码
import urlliburllib.quote('清远')Out[143]: '%E6%B8%85%E8%BF%9C'
2016-08-23 16:13:35 268
原创 python的strip('')函数带参数
In[45]: xOut[45]: ' ----fdaf-dafdfa- 'In[46]: x.strip(' ')Out[46]: '----fdaf-dafdfa-'
2016-08-22 10:32:12 1353
原创 w3lib.html remove_tags()函数 去除html的tags
from w3lib.html import remove_tags#去除html的标签,可用于爬虫处理htmlIn[32]: remove_tags(u'1000')Out[32]: u'1000'In[33]: remove_tags(u'€')Out[33]: u'€'In[34]: remove_tags(
2016-08-22 09:46:11 3708
原创 python str的函数isdigit()
value = u"1" value.isdigit() num = b"1" # bytenum.isdigit() num = "IV" num.isdigit() num = "四"num.isdigit()
2016-08-22 09:32:20 1441
原创 scrapy crawl xxx 利用scrapy.shell.inspect_response 输出爬虫运行信息
在scrapy框架中利用inspect_response在cmd上进入shellimport scrapyfrom scrapy.shell import inspect_responseclass MySpider(scrapy.Spider): name = "example" start_urls = [ "http://example.org"
2016-08-18 16:56:29 1869
原创 python在cmd上传参,用于写接口
#-*-encoding=utf-8-*-import sysprint u'有:', len(sys.argv),u'参数.'print u'参数类型type(sys.argv):',type(sys.argv)print u'参数:sys.argv ',sys.argvprint u'参数:str(sys.argv) ', str(sys.argv)pri
2016-08-18 15:55:07 858
原创 json.loads 把str转换为json
爬虫常用函数 json.loads()In[44]: jsonStrOut[44]: u'{"retcode":"0","uid":"12312312","nick":"\\u60xx\\u60xx\\u806xx","crossDomainUrlList":["https:\\/\\/passport.weibo.com\\/wbsso\\/login?","https:
2016-08-12 11:04:49 957
原创 python 时间戳与时间之间的转换
time_list = {u"昨天":time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()-60*60*24)), u"前天":time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()-60*60*24*2)),
2016-08-09 16:33:44 1598
mysqlclient-1.3.12-cp27-cp27m-win_amd64.whl
2018-02-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人