我想从给定的xpath中提取值:
file_names = ['01012017_alp.csv', '01012017_idk.csv', '01012017_kan.csv',
'01012017_klm.csv', '01022017_kas.csv', '01022017_mlp.csv']
monthDict = {'01': [] , '02': [], '03': [], '04': [], '05': [], '06': [], '07': [], '08': [], '09': [], '10': [], '11': [], '12': []}
for file in file_names:
print(file[2:4])
for key, value in monthDict.items():
if file[2:4] == key:
value.append(file)
print(monthDict)
到Python。
'//*[@id="octable"]/tbody/tr[34]/td[8]/b
预期结果:import requests
from lxml import html
pageContent=requests.get('https://nseindia.com/live_market/dynaContent/live_watch/option_chain/optionKeys.jsp?symbolCode=209&symbol=INFY&symbol=INFY&instrument=-&date=-&segmentLink=17&symbolCount=2&segmentLink=17')
tree = html.fromstring(pageContent.content)
g=tree.xpath('//*[@id="octable"]/tbody/tr[34]/td[8]/b/text()')
print(g)
实际结果:7,962,000
答案 0 :(得分:0)
使用import { Component } from 'react';
import * as THREE from 'three';
import React3 from 'react-three-renderer';
import logo from './logo.svg';
import './App.css';
export default class Shape extends Component {
constructor(props, context) {
super(props, context);
this.state = {
...this.state,
timer: Date.now() * 0.0001,
scene: {},
};
this.objectPositions = [
new THREE.Vector3(-400, 0, 200),
];
}
render() {
const {
timer,
} = this.state;
const objectRotation = new THREE.Euler(
timer * 5,
timer * 2.5,
0,
);
return(
<mesh
position={this.objectPositions[0]}
rotation={objectRotation}
>
<icosahedronGeometry
radius={75}
detail={1}
/>
<materialResource
resourceId="material"
/>
</mesh>
);
}
代替
g=tree.xpath('//*[@id="octable"]/tr/td[8]/b/text()')
产生了预期的结果。