随笔分类 - 爬虫
摘要:#coding:utf-8 import urllib2 proxyswitch = True httpproxy_handler = urllib2.ProxyHandler({"http":"211.159.177.212:3128"}) nullproxy_handler = urllib2.ProxyHandler({}) if proxyswitch: opener =...
阅读全文
摘要:#coding:utf-8 import urllib2 #构建一个HTTPandler处理对象,支持处理HTTP的请求 http_handler = urllib2.HTTPHandler() #调用build_opener()方法构建一个自定义的opener对象,参数是构建的处理器对象 opener = urllib2.build_opener(http_handler) request...
阅读全文
摘要:#coding:utf-8 import urllib2 url = "http://www.renren.com/247277361/profile" headers = { "host":"www.renren.com", "connection":"keep-alive", #"upgrade-insecure-requests":"1", "use...
阅读全文
摘要:#coding:utf-8 import urllib import urllib2 url = "https://movie.douban.com/j/new_search_subjects?" headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, li...
阅读全文
摘要:0 0 #coding:utf-8 import urllib import urllib2 def loadPage(url,filename): ''' 作用:根据url发送请求,获取服务器响应文件 url:需要爬去的url地址 filename : 处理的文件名 ''' print "正在下载
阅读全文
摘要:# coding:utf-8 import urllib import urllib2 url = "http://wwww.baidu.com/s" headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3...
阅读全文
摘要:下载地址:https://www.telerik.com/fiddler APP手机爬取(转:http://blog.csdn.net/c406495762/article/details/76850843)
阅读全文
摘要:# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html impo...
阅读全文
摘要:spider.py文件配置 1 2 # -*- coding: utf-8 -*- 3 import scrapy 4 from itTeachers.items import ItteachersItem 5 6 7 class ItcastSpider(scrapy.Spider): 8 name = 'itcast' 9 allo...
阅读全文
摘要:24 quote = each.xpath(".//p[@class='quote']/span/text()").extract() 25 if len(quote) != 0: 26 item['quote'] = quote[0] 27 28 29 yield item 30 31 if se
阅读全文
摘要:转:http://blog.csdn.net/xiangwanpeng/article/details/54586087 :https://www.cnblogs.com/wangchunniu1314/p/6339416.html
阅读全文
摘要:7.vi pipelines.py 8.vi settings.py 9.cd spiders 12 scrapy crawl qqcent
阅读全文
摘要:sudo apt-get install python-virtualenv virtualenv py2 cd py2 cd bin 启动虚拟环境:source activate deactivate virtualenv -p /usr/bin/pyhon3 py3 cd py3 cd bin source activate pip install virtualenvwrapper...
阅读全文
摘要:pip install virtualenv 下载模块使用国内镜像:pip install -i https://pypi.douban.com/simple/ django 新建虚拟环境:virtualenv scrapytest cd scrapytest cd Scrapytest 运行:activate.bat 退出:deactivae.bat virtualenv -p C:\User...
阅读全文
摘要:Python自带的模块:/usr/lib/python2.7/urllib2.py Python的第三方模块:/usr/local/lib/python2.7/site-packages:hh
阅读全文

浙公网安备 33010602011771号