BeautifulSoup数据反应型Python

时间:2018-11-11 19:08:59

标签: python python-3.x beautifulsoup

尝试使用数据反应堆标记在Yahoo Finance中搜索号码,但是我得到了SyntaxError: keyword can't be an expression。我的代码:

Walmart stock
source = requests.get('https://finance.yahoo.com/quote/WMT?p=WMT&.tsrc=fin-srch').text
soup = BeautifulSoup(source, 'lxml')
price = soup.find('span', data-reactid_='35')
print("Walmart stock: " + price.text)

2 个答案:

答案 0 :(得分:0)

您只是做错了一点。在我看来,使用dict比使用add_action( 'woocommerce_admin_order_data_after_shipping_address', 'additional_admin_order_data_block_after_shipping_address', 100 ); function additional_admin_order_data_block_after_shipping_address(){ echo '</div><div class="order_data_column"> <h3>' . esc_html__( 'Block title', 'woocommerce' ) . '</h3>'; // here goes your code and content // Fake content output just for testing echo '<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.</p>'; }

更灵活
class_=

答案 1 :(得分:0)

尝试一下。

import quandl
quandl.ApiConfig.api_key = 'e6Rbk-YUCGHVbt5kDAh_'

# get the table for daily stock prices and,
# filter the table for selected tickers, columns within a time range
# set paginate to True because Quandl limits tables API to 10,000 rows per call

data = quandl.get_table('WIKI/PRICES', ticker = ['WMT'], 
                        qopts = { 'columns': ['ticker', 'date', 'adj_close'] }, 
                        date = { 'gte': '2015-12-31', 'lte': '2016-12-31' }, 
                        paginate=True)
print(data)

这也许也值得一看。

https://www.quandl.com/api/v3/datasets/EOD/WMT.csv?api_key=your_api_key-oges_here