我试图从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')
您之所以观察到按钮的“蓝色”是因为使用中的可插拔外观(PLAF)添加了渐变或其他效果。颜色实际上是灰色的,但渐变使它看起来是蓝色的。我猜你用的是金属板,有这种效果
如果将按钮的UI替换为非PLAF UI:
然后按钮将保留默认颜色,而不必使用
setBackground
或setContentAreaFilled
调用} 的文档:
setBackground
可以消除渐变或其他特殊效果的原因是,各个LAF对背景颜色的处理方式不同。金属LAF完全消除了这种影响。windows系统LAF实际上忽略了背景色,只显示带有颜色的薄边框。注意^{相关问题 更多 >
编程相关推荐