随笔分类 - python爬虫
摘要:爬取豆瓣top250部电影 创建表: connect.py from sqlalchemy import create_engine HOSTNAME='localhost' PORT='3306' USERNAME='root' PASSWORD='123456' DATABASE='douban
阅读全文
摘要:scrapy.py 1.cmd运行scrapy shell http://www.baidu.com response.xpath('//div[@aa="bb"]') 找到需要匹配的内容 ##仅供参考语法,内容不准确 2.cmd运行: scrapy startproject sunbeam(名字随意) 然后在pycharm打开项目sunbeam 3.在items.py编辑需要爬...
阅读全文
摘要:1.安装Python 安装完了记得配置环境,将python目录和python目录下的Scripts目录添加到系统环境变量的Path里。在cmd中输入python如果出现版本信息说明配置完毕 2.安装lxml lxml是一种使用 Python 编写的库,可以迅速、灵活地处理 XML。网址https:/
阅读全文
摘要:.content是二进制 用来处理声音、图片、视频 .text是文本 xpath语法: /一层层查找 //不固定位置 //title/text() @选取属性 [@href]和[@href=''] .当前位置 ``* //div[@*] 选取所有带属性的div contains contains[@
阅读全文
摘要:```python
# -*- coding: cp936 -*- import urllib,urllib2
from bs4 import BeautifulSoup user_agent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safa...
阅读全文
摘要:``` #-*- coding:utf-8 -*- #from __future__ import unicode_liter import urllib,urllib2 import re,sys,os,time headers={ 'Referer':'http://jandan.net/', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64)...
阅读全文
摘要:``` py2版本: #-*- coding:utf-8 -*- #from __future__ import unicode_liter import urllib,urllib2,time import re,sys,os headers={ 'Referer':'http://jandan.net/', 'User-Agent':'Mozilla/5.0 (Windows NT 1...
阅读全文