以下のコード。空白を返す代わりに値「INDICES」を返すことになっていますか? 他のサイトで動作するのを見たことがありますが、ここでは失敗しているようです。以下のすべての試行は空白を返します
import requests
from lxml import html
pageContent=requests.get('https://finviz.com/futures.ashx')
tree = html.fromstring(pageContent.content)
Indicies = tree.xpath('//div[contains(@class, "tile_header is-indices")]//*')
Indicies = tree.xpath('//*[@id="futures"]/div/div[2]/div[1]/a[1]/div[1]/text()')
Indicies = tree.xpath('/html/body/div[2]/div/div/div/div[2]/div[1]/a[1]/div[1]')
print([e.text_content() for e in tree.xpath('//div[@class="tile_header is-indices" and @style]')])
Indicies = tree.xpath("//div[contains(text(), 'tile_header is-indices')]//*")
Indicies = tree.xpath("//a[contains(text(), 'tile_header is-indices')]//*")
var groups = [{"ticker":"INDICES","label":"Indices","contracts":[{"label":"DJIA","ticker":"YM","cot":"124601,124603"}