有什么问题吗

2024-09-23 22:31:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从moneycontrol.com网站上获取股票的成交量加权平均价格。parse函数运行没有任何问题,但是parse_links函数没有被调用。我是不是少了点什么?在

# -*- coding: utf-8 -*-
import scrapy

class MoneycontrolSpider(scrapy.Spider):
    name = "moneycontrol"
    allowed_domains = ["https://www.moneycontrol.com"]
    start_urls = ["https://www.moneycontrol.com/india/stockpricequote"]

    def parse(self,response):
        for link in response.css('td.last > a::attr(href)').extract():
            if(link):
                yield scrapy.Request(link, callback=self.parse_links,method='GET')

    def parse_links(self, response):
        VWAP= response.xpath('//*[@id="n_vwap_val"]/text()').extract_first()
        print(VWAP)      
        with open('quotes.txt','a+') as f:
            f.write('VWAP: {}'.format(VWAP)  + '\n')

Tags: 函数httpsselfcomparse网站responsedef
1条回答
网友
1楼 · 发布于 2024-09-23 22:31:46

您之所以观察到按钮的“蓝色”是因为使用中的可插拔外观(PLAF)添加了渐变或其他效果。颜色实际上是灰色的,但渐变使它看起来是蓝色的。我猜你用的是金属板,有这种效果

如果将按钮的UI替换为非PLAF UI:

justButton.setUI((ButtonUI)BasicButtonUI.createUI(justButton));

然后按钮将保留默认颜色,而不必使用setBackgroundsetContentAreaFilled

调用setBackground可以消除渐变或其他特殊效果的原因是,各个LAF对背景颜色的处理方式不同。金属LAF完全消除了这种影响。windows系统LAF实际上忽略了背景色,只显示带有颜色的薄边框。注意^{}的文档:

It is up to the look and feel to honor this property, some may choose to ignore it.

enter image description here

相关问题 更多 >