• 大小: 1.41MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: Python
  • 标签:

资源简介

此爬虫主要基于Scrapy MySQL爬取链家网中,北京地区的租房信息。 Python版本为Python3.6

资源截图

代码片段和文件信息

# -*- coding=utf-8 -*-
import MySQLdb
account = input(‘请输入MySQL用户名\n >‘)
password = input(‘请输入MySQL密码\n >‘)
table = input(‘请输入数据库名称\n >‘)
# 连接数据库
db = MySQLdb.connect(‘localhost‘account str(password) table)
# 获取游标
cursor = db.cursor()
sql = “““CREATE TABLE lianjia(
    title VARCHAR(30)
    LOCATION VARCHAR(100)
    ZONE VARCHAR(10)
    METERS VARCHAR(10)
    DIRECTION VARCHAR(10)
    MONEY VARCHAR(10)

“““
# 执行sql语句
cursor.execute(sql)
# 关闭数据库
db.close()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-08 04:02  LianjiaSpider-master\
     文件          65  2018-01-08 04:02  LianjiaSpider-master\.gitattributes
     文件        1063  2018-01-08 04:02  LianjiaSpider-master\LICENSE
     文件         435  2018-01-08 04:02  LianjiaSpider-master\README.md
     文件         543  2018-01-08 04:02  LianjiaSpider-master\database.py
     目录           0  2018-01-08 04:02  LianjiaSpider-master\screenshots\
     文件     1452678  2018-01-08 04:02  LianjiaSpider-master\screenshots\mysql.png
     目录           0  2018-01-08 04:02  LianjiaSpider-master\src\
     目录           0  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\
     文件           0  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__init__.py
     目录           0  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\
     文件         152  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\__init__.cpython-36.pyc
     文件         456  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\items.cpython-36.pyc
     文件        1590  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\middlewares.cpython-36.pyc
     文件        1164  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\pipelines.cpython-36.pyc
     文件         795  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\proxy_middleware.cpython-36.pyc
     文件         688  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\settings.cpython-36.pyc
     文件        2857  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\__pycache__\useragent_middleware.cpython-36.pyc
     文件         656  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\items.py
     文件        1911  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\middlewares.py
     文件         917  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\pipelines.py
     文件         392  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\proxy_middleware.py
     文件        3704  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\settings.py
     目录           0  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\
     文件        1705  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\LianjiaSpider.py
     文件         161  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__init__.py
     目录           0  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__pycache__\
     文件        1480  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__pycache__\LianjiaSpider.cpython-36.pyc
     文件         160  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__pycache__\__init__.cpython-36.pyc
     文件         173  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__pycache__\downloader_middleware.cpython-36.pyc
     文件         932  2018-01-08 04:02  LianjiaSpider-master\src\LianjiaSpider\spiders\__pycache__\middlewares.cpython-36.pyc
............此处省略4个文件信息

评论

共有 条评论