美文网首页
180801--实战范例-房天下(Fang.com)--26

180801--实战范例-房天下(Fang.com)--26

作者: 投资麻辣烫 | 来源:发表于2018-08-01 16:49 被阅读31次

需要爬取文字标题

在 headers 下面  有 网页,然后Request 是 GET

把 Response 这个里面的文本框复制到 TXT 并保存至 Python 根目录

import requests

res=requests.get('http://esf.sh.fang.com')

#res.text

from bs4 import BeautifulSoup

domain = 'http://esf.sh.fang.com'

soup=BeautifulSoup(res.text,'html.parser')

for house in soup.select('.houseList dl'):

    title = house.select('.title')[0].text.strp()

    print(domain + house.selec('.title a')[0]['href'])

    print("=============")

码了一堆没用的代码

因为网页更新了,但我还没有熟练使用。明天换教程

相关文章

网友评论

      本文标题:180801--实战范例-房天下(Fang.com)--26

      本文链接:https://www.haomeiwen.com/subject/cbfrvftx.html