如何从不同的索引位置删除/删除Python列表中的文本

时间:2017-07-29 20:16:23

标签: python-3.x web-scraping

我尝试了几种方法来提取我想要的单词,但我无法做到。完成需要这样:

https://drive.google.com/open?id=0BzzXkoIWuMAHUjFuT2IteEtLVjQ

提取文本后,我可以将它们放入CSV文件

from urllib.request import urlopen as uReq
from urllib.request import Request
from bs4 import BeautifulSoup as soup

AccessCME=Request('http://www.cmegroup.com/trading/energy/natural-
gas/natural-gas_contract_specifications.html',headers={"User-
Agent":"Mozilla/5.0"})
CMEPage=uReq(AccessCME).read()
page_soup=soup(CMEPage,"html.parser")

possible_tds=page_soup.find_all('td',attrs={'class':'prodSpecAtribute'})
parent_td=[td for td in possible_tds if 'Trading' in td.text][0]

Target=parent_td.fetchNextSiblings('td')[1].text

print(Target)

New=Target.split(" ")
print(New)

0 个答案:

没有答案