会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133662个问题
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 23702楼
WEB前端全系列/第十三阶段:微信小程序-安心食疗(旧)/安心食疗-页面跳转 23703楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 23704楼

IMG_20210319_190008.jpg

类似于途中的报错算是什么情况呢?请老师帮忙解惑,谢谢!

JAVA 全系列/第一阶段:AI驱动的JAVA编程/控制语句、方法、递归算法 23705楼

代码:

import scrapy


class BizhizuSpider(scrapy.Spider):
    name = 'bizhizu'
    allowed_domains = ['bizhizu.cn']
    # start_urls = ['https://www.bizhizu.cn/pic/7097.html']
    start_urls=['https://www.bizhizu.cn/pic/7097-0.html']

    def parse(self, response):
        image_url=response.xpath('//div[@class="pic"]/a[@id="photoimg"]/img/@src').extract_first()
        print(image_url)
        image_name=response.xpath('string(//div[@class="txt"]/h1)').extract_first()
        print(image_name)
        yield{
            "image_url":image_url,
            "image_name":image_name
        }
        next_url=response.xpath('//div[@class="photo_next"]//a/@href').extract_first()
        yield scrapy.Request(next_url,callback=self.parse)
from scrapy.pipelines.images import ImagesPipeline
from scrapy import Request
class PicturePipeline(ImagesPipeline):
    def get_media_requests(self, item, info):
        yield Request(item["image_url"],meta={"name":item["image_name"]})
    def file_path(self, request, response=None, info=None,*,item=None):
        name=request.meta["name"].strip()
        name=name.replace("/","_")
        return name+'.jpg'

运行结果:

屏幕截图 2021-03-19 184131.png老师请问一下,为什么我在爬取淘女郎图片的时候,每次爬取的图片名称都是一样的,但是image_url是不同的,麻烦老师帮我看看程序哪里出问题了?

Python 全系列/第十六阶段:Python 爬虫开发/scrapy 框架高级 23706楼
JAVA 全系列/第六阶段:项目管理与SSM框架/Spring 23707楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/容器(旧) 23708楼

<template>
    <div>
        <button @cilck="showA">A组件</button>
        <button @click="showB">B组件</button>
        <button @click="showC">kong组件</button>
        <keep-alive>
            <component :is="current"></component>
        </keep-alive>
        

        动态组件    
    </div>
</template>

<script>
import AComponent from "./child/AComponent";
import BComponent from "./child/BComponent";
export default {
    name:"dongtai_components",
    data(){
        return{
            current:AComponent,

        }
    },
    components:{
        AComponent,
        BComponent,
    },methods:{
        showA(){
            this.current=AComponent;
        },
        showB(){
            this.current=BComponent;
        },showC(){
            this.current=AComponent;
        }


    }
}
</script>
<template>
    <div>
        AComponentaaa
    </div>
</template>
<script>
export default {
    name:"AComponent",
    data(){
        return{

        }
    }
}
</script>
<template>
    <div>
        BComponent
        {{msg}}
        <button @click="handle">改变数据</button>
        
    </div>
</template>
<script>
export default {
    name:"BComponent",
    data(){
        return{
            msg:"原有数据"

        }
    },
    methods:{
        handle(){
            this.msg="这是修改后的数据"

        }
    }
}
</script>

老师我这个showA点击之后没效果,而且把整个showA删除之后,后面两个事件也没效果了。是怎么回事

WEB前端全系列/第十九阶段:Vue2知识体系(旧)/Vue基础知识 23711楼
JAVA 全系列/第二十一阶段:租房网(Spring Cloud最新架构)/Livegoods第一天 23712楼
Python 全系列/第六阶段:数据库与AI协同技术实战/mysql的使用 23713楼

#coding=utf-8
# 通过grid布局-实现计算器软件界面

from tkinter import *
from tkinter import messagebox
import random

class Application(Frame):

    def __init__(self,master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.createWidget

    def createWidget(self):
        """通过grid布局实现计算器界面"""
        btnText = (("MC","M+","M-","MR"),
                   ("C","±","➗","✖"),
                   (7,8,9,"-"),
                   (4,5,6,"+"),
                   (1,2,3,"="),
                   (0,"."))

        Entry(self).grid(row=0,column=0,columnspan=4,pady=10)

        for rindex,r in enumerate(btnText):
            for cindex,c in enumerate(r):
                if c == "=":
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex, rowspan=2,sticky=NSEW)
                elif c == 0:
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex,columnspan=2, sticky=NSEW)
                elif c == ".":
                    Button(self, text=c, width=2).grid(row=rindex+1, column=cindex+1, sticky=NSEW)
                else:
                    Button(self,text=c,width=2).grid(row=rindex+1,column=cindex,sticky=NSEW)




if __name__ == '__main__':
    root = Tk()
    root.geometry("200x200+200+300")
    app = Application(master=root)
    root.mainloop()

image.png

老师,为啥我这出来是这个样子,怎么没有计算器的内容啊,错哪了

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 23714楼
JAVA 全系列/第三十阶段:数据结构和算法BATJ大厂面试重难点/字符串和矩阵 23715楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637