Skip to content

YYL99/house

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

house

scrapy startproject house_transaction创建scrapy框架命名为house_transaction

scrapy genspider a luzhou.58.com/chuzu

设置main.py

主要用于运行scarpy框架

from scrapy.cmdline import execute
import sys
import os
#得到地址
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
execute(["scrapy", "crawl", "a"])

a.py

获得字段

首先在parse方法中爬取所需信息,如当前页中每个房型的网页链接,标题,大小,类型,价格。由于其中的数字通过base64进行编码,因此需要导入base64库和TTFont库进行解码。

import base64
from fontTools.ttLib import TTFont

由于需要解码,对象需要时html类型,因此需要对爬取到的response进行转换res_html = response.text再使用正则表达式获得相关信息。

提取时可在cmd中用scrapy shell + 链接进行调试,避免多次爬取

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages