python span镶嵌匹配_使用beautifulsoup解析嵌套span标记

该程序从Globe网站抓取股票数据,并使用BeautifulSoup解析<span>标签。遇到的问题包括处理嵌套标签和数据组织。代码虽不美观,但有助于学习Python和BeautifulSoup。
摘要由CSDN通过智能技术生成

所以这是工作的方式,比我以前的工作方式要好,但仍然存在一些问题。我发布了完整的脚本,你可以看到我在做什么。我将花费一些时间和精力来研究这些问题,但这将帮助我更好地学习python和beauthulsoup。在"""

This program imports a list of stock ticker symbols from "ca_stocks.txt"

It then goes to the Globe website and gets current company stock data

It then writes this data to a file to a CSV file in the form

index, ticker, date&time, dimension, measure

"""

import urllib2

import csv, os

import datetime

import re #regular expressions library

import bs4

#from bs4 import BeautifulStoneSoup as bss

#from time import gmtime, strftime

#from lxml import etree

import pyquery

#import dataextract as tde

os.chdir('D:\\02 - \\003 INVESTMENTS\\Yahoo Finance Data')

symbolfile = open('ca_stocks2.txt')

symbolslist = symbo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值