• 手机版

    扫码体验手机版

  • 微信公众号

    扫码关注公众号

国内首家协议开发

软芯音视解码保护平台

在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

我的这个Python代码不知道哪里错了,总是不能运行不了我想要的结果。

from bs4 import BeautifulSoupimport requestsimport timeinfo = []url = 'http://cq.xiaozhu.com/search-duanzufang-p1-0/'url_save = 'http://cq.xiaozhu.com/fangzi/4783366714.html'urls = ['http://cq.xiaozhu.com/search-duanzufang-p{}-0/'.format(str(i)) for i in range(1, 14)]def get_fav(url, data=None):    web_data = requests.get(url)    time.sleep(2)    Soup = BeautifulSoup(web_data.text, 'lxml')    webs = Soup.select('#page_list > ul > li > a[target="_blank"]')    if data is None:        for web in webs:            print(web.get('href'))def get_info(url_1, data=None):    web_data = requests.get(url_1)    Soup = BeautifulSoup(web_data.text, 'lxml')    titles = Soup.select('body > div.wrap.clearfix.con_bg > div.con_l > div.pho_info > h4 > em')    sites = Soup.select('body > div.wrap.clearfix.con_bg > div.con_l > div.pho_info > p')    prices = Soup.select('#pricePart > div.day_l > span')    images = Soup.select('#curBigImage')    avatars = Soup.select('#floatRightBox > div.js_box.clearfix > div.member_pic > a > img')    names = Soup.select('#floatRightBox > div.js_box.clearfix > div.w_240 > h6 > a')    sexs = Soup.select('#floatRightBox > div.js_box.clearfix > div.member_pic > div')    if data is None:        for title, site, price, image, avatar, name, sex in zip(titles, sites, prices, images, avatars, names, sexs):            data = {                'title': title.get_text(),                'site': site.get('title'),                'price': price.get_text(),                'image': image.get('src'),                'avatar': avatar.get('src'),                'name': name.get_text(),            }            print(data)for single in urls:    get_fav(single)运行效果出来应该是每个租房链接中,租房名称,租房价格,租房地点,户主照片,户主ID等信息”

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与1

大哥 你现在解决了吗 为啥错的 我跟你用一本书

使用道具 举报

发新帖

发布任务需求已有1031167位用户正在使用天盟网服务

发布分类: *
任务预算: *
需求内容: *
手机号码: *
任务商家报价为
  • 预算价 :
  • 成交价 :
  • 完工期 :
  • 质保期 :

* 最终任务项目以服务商报价、双方协商为准!