【发布时间】:2018-01-27 05:43:02
【问题描述】:
以下代码返回一个空列表
import requests
from bs4 import BeautifulSoup
from lxml import html
YrlyURL=str("http://www.moneycontrol.com/financials/20microns/balance-sheetVI/2M#2M")
page3 = requests.get(YrlyURL, timeout=5)
soup3 = BeautifulSoup(page3.content, "lxml")
tree2 = html.fromstring(page3.content)
yr1 = tree2.xpath('//*[@id="mc_mainWrapper"]/div[3]/div[2]/div[3]/div[2]/div[2]/div[2]/div[1]/table[2]/tbody/tr[1]/td[2]')
print(yr1)
我需要 yr1 才能返回“3 月 17 日”,但我无法找到解决方案。请帮助我了解我做错了什么以及我需要在哪里进行更正。
问候。
【问题讨论】:
标签: python-3.x xpath