爬取转转网站


import requests
from bs4 import  BeautifulSoup

def get_time_info(url):
    url = "http://zhuanzhuan.58.com/detail/926455279137210889z.shtml?fullCate=&fullLocal=&zzfrom=NaN&zhuanzhuanSourceFrom1223"
    wb_data = requests.get(url)
    soup = BeautifulSoup(wb_data.text, "lxml")
    title_list = soup.select("h1.info_titile")
    title = title_list[0].text
    price_list = soup.select('span.price_now > i')
    price = price_list[0].text
    views_list =soup.select('span.look_time')
    views =views_list[0].text
    area_list = soup.select('div.palce_li > span > i')
    area = area_list[0].text
    cate_list =soup.select('span.crb_i > a')
    cate = cate_list[-1].text

    data = {
        'title': title,
        'views': views,
        'price': price,
        'area': area,
        'cate': cate,
    }
    print(data)

def get_all_items_info():
    url = "http://hz.58.com/bijiben/"
    wb_date = requests.get(url)
    soup =BeautifulSoup(wb_date.text,'lxml')
    print(soup)
    hrefs_list = soup.select('a.t')
    for href in hrefs_list:
      link = href.get('href')
      if 'zhuanzhuan' in link:
           get_time_info(link)

get_all_items_info()


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值